microboard-temp 0.5.38 → 0.5.40

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.
@@ -7070,7 +7070,8 @@ var conf = {
7070
7070
  cursorsMap,
7071
7071
  DECK_HORIZONTAL_OFFSET: 2,
7072
7072
  DECK_VERTICAL_OFFSET: 2,
7073
- CARD_DIMENSIONS: { width: 250, height: 400 }
7073
+ CARD_DIMENSIONS: { width: 250, height: 400 },
7074
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
7074
7075
  };
7075
7076
  initDefaultI18N();
7076
7077
 
@@ -21485,6 +21486,7 @@ class BaseItem extends Mbr {
21485
21486
  shouldRenderOutsideViewRect = true;
21486
21487
  shouldUseRelativeAlignment = true;
21487
21488
  enableResize = true;
21489
+ onlyProportionalResize = false;
21488
21490
  itemType = "";
21489
21491
  children = [];
21490
21492
  constructor(board, id = "", defaultItemData, isGroupItem) {
@@ -47853,7 +47855,8 @@ var defaultCardData = {
47853
47855
  itemType: "Card",
47854
47856
  isOpen: false,
47855
47857
  faceUrl: "",
47856
- backsideUrl: ""
47858
+ backsideUrl: "",
47859
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
47857
47860
  };
47858
47861
 
47859
47862
  class Card extends BaseItem {
@@ -47866,9 +47869,13 @@ class Card extends BaseItem {
47866
47869
  backside = null;
47867
47870
  imageToRender = null;
47868
47871
  shouldUseCustomRender = false;
47869
- enableResize = false;
47870
- constructor(board, id = "", urls) {
47872
+ onlyProportionalResize = true;
47873
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
47874
+ constructor(board, id = "", urls, dimensions) {
47871
47875
  super(board, id, defaultCardData);
47876
+ if (dimensions) {
47877
+ this.dimensions = dimensions;
47878
+ }
47872
47879
  if (urls) {
47873
47880
  this.faceUrl = urls.faceUrl;
47874
47881
  this.backsideUrl = urls.backsideUrl;
@@ -47886,6 +47893,9 @@ class Card extends BaseItem {
47886
47893
  });
47887
47894
  this.updateMbr();
47888
47895
  }
47896
+ getDimensions() {
47897
+ return this.dimensions;
47898
+ }
47889
47899
  createImages() {
47890
47900
  this.face = conf.documentFactory.createElement("img");
47891
47901
  this.backside = conf.documentFactory.createElement("img");
@@ -47941,8 +47951,8 @@ class Card extends BaseItem {
47941
47951
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
47942
47952
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
47943
47953
  div.id = this.getId();
47944
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
47945
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
47954
+ div.style.width = `${this.dimensions.width}px`;
47955
+ div.style.height = `${this.dimensions.height}px`;
47946
47956
  div.style.transformOrigin = "top left";
47947
47957
  div.style.transform = transform;
47948
47958
  div.style.position = "absolute";
@@ -47953,8 +47963,8 @@ class Card extends BaseItem {
47953
47963
  updateMbr() {
47954
47964
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47955
47965
  const rotation = this.transformation.getRotation();
47956
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47957
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47966
+ const height3 = this.dimensions.height * scaleY;
47967
+ const width2 = this.dimensions.width * scaleX;
47958
47968
  if (rotation % 180 === 0) {
47959
47969
  this.left = translateX;
47960
47970
  this.top = translateY;
@@ -48095,7 +48105,9 @@ class Deck extends BaseItem {
48095
48105
  childIds.forEach((childId) => {
48096
48106
  const foundItem = this.board.items.getById(childId);
48097
48107
  if (this.parent !== childId && this.getId() !== childId) {
48098
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
48108
+ const firstCard = this.getFirstCard();
48109
+ const firstCardDimensions = firstCard?.getDimensions();
48110
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
48099
48111
  if (canAddItem) {
48100
48112
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
48101
48113
  foundItem.transformation.apply({
@@ -48105,6 +48117,19 @@ class Deck extends BaseItem {
48105
48117
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
48106
48118
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
48107
48119
  });
48120
+ if (firstCard) {
48121
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
48122
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
48123
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
48124
+ foundItem.transformation.apply({
48125
+ class: "Transformation",
48126
+ method: "scaleTo",
48127
+ item: [this.id],
48128
+ x: targetScaleX,
48129
+ y: targetScaleY
48130
+ });
48131
+ }
48132
+ }
48108
48133
  this.board.selection.remove(foundItem);
48109
48134
  this.board.items.index.remove(foundItem);
48110
48135
  foundItem.parent = this.getId();
@@ -48269,6 +48294,9 @@ class Deck extends BaseItem {
48269
48294
  this.isCacheDirty = false;
48270
48295
  this.updateMbr();
48271
48296
  }
48297
+ getFirstCard() {
48298
+ return this.index?.list()[0];
48299
+ }
48272
48300
  }
48273
48301
  registerItem({
48274
48302
  item: Deck,
@@ -51777,7 +51805,7 @@ function transformItems({
51777
51805
  setSnapCursorPos
51778
51806
  }) {
51779
51807
  const items = selection.items.list();
51780
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
51808
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
51781
51809
  if (includesProportionalItem && (isWidth || isHeight)) {
51782
51810
  return null;
51783
51811
  }
package/dist/cjs/index.js CHANGED
@@ -7070,7 +7070,8 @@ var conf = {
7070
7070
  cursorsMap,
7071
7071
  DECK_HORIZONTAL_OFFSET: 2,
7072
7072
  DECK_VERTICAL_OFFSET: 2,
7073
- CARD_DIMENSIONS: { width: 250, height: 400 }
7073
+ CARD_DIMENSIONS: { width: 250, height: 400 },
7074
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
7074
7075
  };
7075
7076
  initDefaultI18N();
7076
7077
 
@@ -21485,6 +21486,7 @@ class BaseItem extends Mbr {
21485
21486
  shouldRenderOutsideViewRect = true;
21486
21487
  shouldUseRelativeAlignment = true;
21487
21488
  enableResize = true;
21489
+ onlyProportionalResize = false;
21488
21490
  itemType = "";
21489
21491
  children = [];
21490
21492
  constructor(board, id = "", defaultItemData, isGroupItem) {
@@ -47853,7 +47855,8 @@ var defaultCardData = {
47853
47855
  itemType: "Card",
47854
47856
  isOpen: false,
47855
47857
  faceUrl: "",
47856
- backsideUrl: ""
47858
+ backsideUrl: "",
47859
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
47857
47860
  };
47858
47861
 
47859
47862
  class Card extends BaseItem {
@@ -47866,9 +47869,13 @@ class Card extends BaseItem {
47866
47869
  backside = null;
47867
47870
  imageToRender = null;
47868
47871
  shouldUseCustomRender = false;
47869
- enableResize = false;
47870
- constructor(board, id = "", urls) {
47872
+ onlyProportionalResize = true;
47873
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
47874
+ constructor(board, id = "", urls, dimensions) {
47871
47875
  super(board, id, defaultCardData);
47876
+ if (dimensions) {
47877
+ this.dimensions = dimensions;
47878
+ }
47872
47879
  if (urls) {
47873
47880
  this.faceUrl = urls.faceUrl;
47874
47881
  this.backsideUrl = urls.backsideUrl;
@@ -47886,6 +47893,9 @@ class Card extends BaseItem {
47886
47893
  });
47887
47894
  this.updateMbr();
47888
47895
  }
47896
+ getDimensions() {
47897
+ return this.dimensions;
47898
+ }
47889
47899
  createImages() {
47890
47900
  this.face = conf.documentFactory.createElement("img");
47891
47901
  this.backside = conf.documentFactory.createElement("img");
@@ -47941,8 +47951,8 @@ class Card extends BaseItem {
47941
47951
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
47942
47952
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
47943
47953
  div.id = this.getId();
47944
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
47945
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
47954
+ div.style.width = `${this.dimensions.width}px`;
47955
+ div.style.height = `${this.dimensions.height}px`;
47946
47956
  div.style.transformOrigin = "top left";
47947
47957
  div.style.transform = transform;
47948
47958
  div.style.position = "absolute";
@@ -47953,8 +47963,8 @@ class Card extends BaseItem {
47953
47963
  updateMbr() {
47954
47964
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47955
47965
  const rotation = this.transformation.getRotation();
47956
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47957
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47966
+ const height3 = this.dimensions.height * scaleY;
47967
+ const width2 = this.dimensions.width * scaleX;
47958
47968
  if (rotation % 180 === 0) {
47959
47969
  this.left = translateX;
47960
47970
  this.top = translateY;
@@ -48095,7 +48105,9 @@ class Deck extends BaseItem {
48095
48105
  childIds.forEach((childId) => {
48096
48106
  const foundItem = this.board.items.getById(childId);
48097
48107
  if (this.parent !== childId && this.getId() !== childId) {
48098
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
48108
+ const firstCard = this.getFirstCard();
48109
+ const firstCardDimensions = firstCard?.getDimensions();
48110
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
48099
48111
  if (canAddItem) {
48100
48112
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
48101
48113
  foundItem.transformation.apply({
@@ -48105,6 +48117,19 @@ class Deck extends BaseItem {
48105
48117
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
48106
48118
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
48107
48119
  });
48120
+ if (firstCard) {
48121
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
48122
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
48123
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
48124
+ foundItem.transformation.apply({
48125
+ class: "Transformation",
48126
+ method: "scaleTo",
48127
+ item: [this.id],
48128
+ x: targetScaleX,
48129
+ y: targetScaleY
48130
+ });
48131
+ }
48132
+ }
48108
48133
  this.board.selection.remove(foundItem);
48109
48134
  this.board.items.index.remove(foundItem);
48110
48135
  foundItem.parent = this.getId();
@@ -48269,6 +48294,9 @@ class Deck extends BaseItem {
48269
48294
  this.isCacheDirty = false;
48270
48295
  this.updateMbr();
48271
48296
  }
48297
+ getFirstCard() {
48298
+ return this.index?.list()[0];
48299
+ }
48272
48300
  }
48273
48301
  registerItem({
48274
48302
  item: Deck,
@@ -51777,7 +51805,7 @@ function transformItems({
51777
51805
  setSnapCursorPos
51778
51806
  }) {
51779
51807
  const items = selection.items.list();
51780
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
51808
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
51781
51809
  if (includesProportionalItem && (isWidth || isHeight)) {
51782
51810
  return null;
51783
51811
  }
package/dist/cjs/node.js CHANGED
@@ -8107,7 +8107,8 @@ var conf = {
8107
8107
  cursorsMap,
8108
8108
  DECK_HORIZONTAL_OFFSET: 2,
8109
8109
  DECK_VERTICAL_OFFSET: 2,
8110
- CARD_DIMENSIONS: { width: 250, height: 400 }
8110
+ CARD_DIMENSIONS: { width: 250, height: 400 },
8111
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
8111
8112
  };
8112
8113
  initDefaultI18N();
8113
8114
 
@@ -23957,6 +23958,7 @@ class BaseItem extends Mbr {
23957
23958
  shouldRenderOutsideViewRect = true;
23958
23959
  shouldUseRelativeAlignment = true;
23959
23960
  enableResize = true;
23961
+ onlyProportionalResize = false;
23960
23962
  itemType = "";
23961
23963
  children = [];
23962
23964
  constructor(board, id = "", defaultItemData, isGroupItem) {
@@ -50326,7 +50328,8 @@ var defaultCardData = {
50326
50328
  itemType: "Card",
50327
50329
  isOpen: false,
50328
50330
  faceUrl: "",
50329
- backsideUrl: ""
50331
+ backsideUrl: "",
50332
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
50330
50333
  };
50331
50334
 
50332
50335
  class Card extends BaseItem {
@@ -50339,9 +50342,13 @@ class Card extends BaseItem {
50339
50342
  backside = null;
50340
50343
  imageToRender = null;
50341
50344
  shouldUseCustomRender = false;
50342
- enableResize = false;
50343
- constructor(board, id = "", urls) {
50345
+ onlyProportionalResize = true;
50346
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
50347
+ constructor(board, id = "", urls, dimensions) {
50344
50348
  super(board, id, defaultCardData);
50349
+ if (dimensions) {
50350
+ this.dimensions = dimensions;
50351
+ }
50345
50352
  if (urls) {
50346
50353
  this.faceUrl = urls.faceUrl;
50347
50354
  this.backsideUrl = urls.backsideUrl;
@@ -50359,6 +50366,9 @@ class Card extends BaseItem {
50359
50366
  });
50360
50367
  this.updateMbr();
50361
50368
  }
50369
+ getDimensions() {
50370
+ return this.dimensions;
50371
+ }
50362
50372
  createImages() {
50363
50373
  this.face = conf.documentFactory.createElement("img");
50364
50374
  this.backside = conf.documentFactory.createElement("img");
@@ -50414,8 +50424,8 @@ class Card extends BaseItem {
50414
50424
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
50415
50425
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
50416
50426
  div.id = this.getId();
50417
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
50418
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
50427
+ div.style.width = `${this.dimensions.width}px`;
50428
+ div.style.height = `${this.dimensions.height}px`;
50419
50429
  div.style.transformOrigin = "top left";
50420
50430
  div.style.transform = transform;
50421
50431
  div.style.position = "absolute";
@@ -50426,8 +50436,8 @@ class Card extends BaseItem {
50426
50436
  updateMbr() {
50427
50437
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
50428
50438
  const rotation = this.transformation.getRotation();
50429
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
50430
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
50439
+ const height3 = this.dimensions.height * scaleY;
50440
+ const width2 = this.dimensions.width * scaleX;
50431
50441
  if (rotation % 180 === 0) {
50432
50442
  this.left = translateX;
50433
50443
  this.top = translateY;
@@ -50568,7 +50578,9 @@ class Deck extends BaseItem {
50568
50578
  childIds.forEach((childId) => {
50569
50579
  const foundItem = this.board.items.getById(childId);
50570
50580
  if (this.parent !== childId && this.getId() !== childId) {
50571
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
50581
+ const firstCard = this.getFirstCard();
50582
+ const firstCardDimensions = firstCard?.getDimensions();
50583
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
50572
50584
  if (canAddItem) {
50573
50585
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
50574
50586
  foundItem.transformation.apply({
@@ -50578,6 +50590,19 @@ class Deck extends BaseItem {
50578
50590
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
50579
50591
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
50580
50592
  });
50593
+ if (firstCard) {
50594
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
50595
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
50596
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
50597
+ foundItem.transformation.apply({
50598
+ class: "Transformation",
50599
+ method: "scaleTo",
50600
+ item: [this.id],
50601
+ x: targetScaleX,
50602
+ y: targetScaleY
50603
+ });
50604
+ }
50605
+ }
50581
50606
  this.board.selection.remove(foundItem);
50582
50607
  this.board.items.index.remove(foundItem);
50583
50608
  foundItem.parent = this.getId();
@@ -50742,6 +50767,9 @@ class Deck extends BaseItem {
50742
50767
  this.isCacheDirty = false;
50743
50768
  this.updateMbr();
50744
50769
  }
50770
+ getFirstCard() {
50771
+ return this.index?.list()[0];
50772
+ }
50745
50773
  }
50746
50774
  registerItem({
50747
50775
  item: Deck,
@@ -54250,7 +54278,7 @@ function transformItems({
54250
54278
  setSnapCursorPos
54251
54279
  }) {
54252
54280
  const items = selection.items.list();
54253
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
54281
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
54254
54282
  if (includesProportionalItem && (isWidth || isHeight)) {
54255
54283
  return null;
54256
54284
  }
@@ -6907,7 +6907,8 @@ var conf = {
6907
6907
  cursorsMap,
6908
6908
  DECK_HORIZONTAL_OFFSET: 2,
6909
6909
  DECK_VERTICAL_OFFSET: 2,
6910
- CARD_DIMENSIONS: { width: 250, height: 400 }
6910
+ CARD_DIMENSIONS: { width: 250, height: 400 },
6911
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
6911
6912
  };
6912
6913
  initDefaultI18N();
6913
6914
 
@@ -21331,6 +21332,7 @@ class BaseItem extends Mbr {
21331
21332
  shouldRenderOutsideViewRect = true;
21332
21333
  shouldUseRelativeAlignment = true;
21333
21334
  enableResize = true;
21335
+ onlyProportionalResize = false;
21334
21336
  itemType = "";
21335
21337
  children = [];
21336
21338
  constructor(board, id = "", defaultItemData, isGroupItem) {
@@ -47699,7 +47701,8 @@ var defaultCardData = {
47699
47701
  itemType: "Card",
47700
47702
  isOpen: false,
47701
47703
  faceUrl: "",
47702
- backsideUrl: ""
47704
+ backsideUrl: "",
47705
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
47703
47706
  };
47704
47707
 
47705
47708
  class Card extends BaseItem {
@@ -47712,9 +47715,13 @@ class Card extends BaseItem {
47712
47715
  backside = null;
47713
47716
  imageToRender = null;
47714
47717
  shouldUseCustomRender = false;
47715
- enableResize = false;
47716
- constructor(board, id = "", urls) {
47718
+ onlyProportionalResize = true;
47719
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
47720
+ constructor(board, id = "", urls, dimensions) {
47717
47721
  super(board, id, defaultCardData);
47722
+ if (dimensions) {
47723
+ this.dimensions = dimensions;
47724
+ }
47718
47725
  if (urls) {
47719
47726
  this.faceUrl = urls.faceUrl;
47720
47727
  this.backsideUrl = urls.backsideUrl;
@@ -47732,6 +47739,9 @@ class Card extends BaseItem {
47732
47739
  });
47733
47740
  this.updateMbr();
47734
47741
  }
47742
+ getDimensions() {
47743
+ return this.dimensions;
47744
+ }
47735
47745
  createImages() {
47736
47746
  this.face = conf.documentFactory.createElement("img");
47737
47747
  this.backside = conf.documentFactory.createElement("img");
@@ -47787,8 +47797,8 @@ class Card extends BaseItem {
47787
47797
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
47788
47798
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
47789
47799
  div.id = this.getId();
47790
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
47791
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
47800
+ div.style.width = `${this.dimensions.width}px`;
47801
+ div.style.height = `${this.dimensions.height}px`;
47792
47802
  div.style.transformOrigin = "top left";
47793
47803
  div.style.transform = transform;
47794
47804
  div.style.position = "absolute";
@@ -47799,8 +47809,8 @@ class Card extends BaseItem {
47799
47809
  updateMbr() {
47800
47810
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47801
47811
  const rotation = this.transformation.getRotation();
47802
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47803
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47812
+ const height3 = this.dimensions.height * scaleY;
47813
+ const width2 = this.dimensions.width * scaleX;
47804
47814
  if (rotation % 180 === 0) {
47805
47815
  this.left = translateX;
47806
47816
  this.top = translateY;
@@ -47941,7 +47951,9 @@ class Deck extends BaseItem {
47941
47951
  childIds.forEach((childId) => {
47942
47952
  const foundItem = this.board.items.getById(childId);
47943
47953
  if (this.parent !== childId && this.getId() !== childId) {
47944
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
47954
+ const firstCard = this.getFirstCard();
47955
+ const firstCardDimensions = firstCard?.getDimensions();
47956
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
47945
47957
  if (canAddItem) {
47946
47958
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
47947
47959
  foundItem.transformation.apply({
@@ -47951,6 +47963,19 @@ class Deck extends BaseItem {
47951
47963
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
47952
47964
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
47953
47965
  });
47966
+ if (firstCard) {
47967
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
47968
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
47969
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
47970
+ foundItem.transformation.apply({
47971
+ class: "Transformation",
47972
+ method: "scaleTo",
47973
+ item: [this.id],
47974
+ x: targetScaleX,
47975
+ y: targetScaleY
47976
+ });
47977
+ }
47978
+ }
47954
47979
  this.board.selection.remove(foundItem);
47955
47980
  this.board.items.index.remove(foundItem);
47956
47981
  foundItem.parent = this.getId();
@@ -48115,6 +48140,9 @@ class Deck extends BaseItem {
48115
48140
  this.isCacheDirty = false;
48116
48141
  this.updateMbr();
48117
48142
  }
48143
+ getFirstCard() {
48144
+ return this.index?.list()[0];
48145
+ }
48118
48146
  }
48119
48147
  registerItem({
48120
48148
  item: Deck,
@@ -51623,7 +51651,7 @@ function transformItems({
51623
51651
  setSnapCursorPos
51624
51652
  }) {
51625
51653
  const items = selection.items.list();
51626
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
51654
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
51627
51655
  if (includesProportionalItem && (isWidth || isHeight)) {
51628
51656
  return null;
51629
51657
  }
package/dist/esm/index.js CHANGED
@@ -6900,7 +6900,8 @@ var conf = {
6900
6900
  cursorsMap,
6901
6901
  DECK_HORIZONTAL_OFFSET: 2,
6902
6902
  DECK_VERTICAL_OFFSET: 2,
6903
- CARD_DIMENSIONS: { width: 250, height: 400 }
6903
+ CARD_DIMENSIONS: { width: 250, height: 400 },
6904
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
6904
6905
  };
6905
6906
  initDefaultI18N();
6906
6907
 
@@ -21324,6 +21325,7 @@ class BaseItem extends Mbr {
21324
21325
  shouldRenderOutsideViewRect = true;
21325
21326
  shouldUseRelativeAlignment = true;
21326
21327
  enableResize = true;
21328
+ onlyProportionalResize = false;
21327
21329
  itemType = "";
21328
21330
  children = [];
21329
21331
  constructor(board, id = "", defaultItemData, isGroupItem) {
@@ -47692,7 +47694,8 @@ var defaultCardData = {
47692
47694
  itemType: "Card",
47693
47695
  isOpen: false,
47694
47696
  faceUrl: "",
47695
- backsideUrl: ""
47697
+ backsideUrl: "",
47698
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
47696
47699
  };
47697
47700
 
47698
47701
  class Card extends BaseItem {
@@ -47705,9 +47708,13 @@ class Card extends BaseItem {
47705
47708
  backside = null;
47706
47709
  imageToRender = null;
47707
47710
  shouldUseCustomRender = false;
47708
- enableResize = false;
47709
- constructor(board, id = "", urls) {
47711
+ onlyProportionalResize = true;
47712
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
47713
+ constructor(board, id = "", urls, dimensions) {
47710
47714
  super(board, id, defaultCardData);
47715
+ if (dimensions) {
47716
+ this.dimensions = dimensions;
47717
+ }
47711
47718
  if (urls) {
47712
47719
  this.faceUrl = urls.faceUrl;
47713
47720
  this.backsideUrl = urls.backsideUrl;
@@ -47725,6 +47732,9 @@ class Card extends BaseItem {
47725
47732
  });
47726
47733
  this.updateMbr();
47727
47734
  }
47735
+ getDimensions() {
47736
+ return this.dimensions;
47737
+ }
47728
47738
  createImages() {
47729
47739
  this.face = conf.documentFactory.createElement("img");
47730
47740
  this.backside = conf.documentFactory.createElement("img");
@@ -47780,8 +47790,8 @@ class Card extends BaseItem {
47780
47790
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
47781
47791
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
47782
47792
  div.id = this.getId();
47783
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
47784
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
47793
+ div.style.width = `${this.dimensions.width}px`;
47794
+ div.style.height = `${this.dimensions.height}px`;
47785
47795
  div.style.transformOrigin = "top left";
47786
47796
  div.style.transform = transform;
47787
47797
  div.style.position = "absolute";
@@ -47792,8 +47802,8 @@ class Card extends BaseItem {
47792
47802
  updateMbr() {
47793
47803
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47794
47804
  const rotation = this.transformation.getRotation();
47795
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
47796
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
47805
+ const height3 = this.dimensions.height * scaleY;
47806
+ const width2 = this.dimensions.width * scaleX;
47797
47807
  if (rotation % 180 === 0) {
47798
47808
  this.left = translateX;
47799
47809
  this.top = translateY;
@@ -47934,7 +47944,9 @@ class Deck extends BaseItem {
47934
47944
  childIds.forEach((childId) => {
47935
47945
  const foundItem = this.board.items.getById(childId);
47936
47946
  if (this.parent !== childId && this.getId() !== childId) {
47937
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
47947
+ const firstCard = this.getFirstCard();
47948
+ const firstCardDimensions = firstCard?.getDimensions();
47949
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
47938
47950
  if (canAddItem) {
47939
47951
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
47940
47952
  foundItem.transformation.apply({
@@ -47944,6 +47956,19 @@ class Deck extends BaseItem {
47944
47956
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
47945
47957
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
47946
47958
  });
47959
+ if (firstCard) {
47960
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
47961
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
47962
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
47963
+ foundItem.transformation.apply({
47964
+ class: "Transformation",
47965
+ method: "scaleTo",
47966
+ item: [this.id],
47967
+ x: targetScaleX,
47968
+ y: targetScaleY
47969
+ });
47970
+ }
47971
+ }
47947
47972
  this.board.selection.remove(foundItem);
47948
47973
  this.board.items.index.remove(foundItem);
47949
47974
  foundItem.parent = this.getId();
@@ -48108,6 +48133,9 @@ class Deck extends BaseItem {
48108
48133
  this.isCacheDirty = false;
48109
48134
  this.updateMbr();
48110
48135
  }
48136
+ getFirstCard() {
48137
+ return this.index?.list()[0];
48138
+ }
48111
48139
  }
48112
48140
  registerItem({
48113
48141
  item: Deck,
@@ -51616,7 +51644,7 @@ function transformItems({
51616
51644
  setSnapCursorPos
51617
51645
  }) {
51618
51646
  const items = selection.items.list();
51619
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
51647
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
51620
51648
  if (includesProportionalItem && (isWidth || isHeight)) {
51621
51649
  return null;
51622
51650
  }
package/dist/esm/node.js CHANGED
@@ -7684,7 +7684,8 @@ var conf = {
7684
7684
  cursorsMap,
7685
7685
  DECK_HORIZONTAL_OFFSET: 2,
7686
7686
  DECK_VERTICAL_OFFSET: 2,
7687
- CARD_DIMENSIONS: { width: 250, height: 400 }
7687
+ CARD_DIMENSIONS: { width: 250, height: 400 },
7688
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
7688
7689
  };
7689
7690
  initDefaultI18N();
7690
7691
 
@@ -23791,6 +23792,7 @@ class BaseItem extends Mbr {
23791
23792
  shouldRenderOutsideViewRect = true;
23792
23793
  shouldUseRelativeAlignment = true;
23793
23794
  enableResize = true;
23795
+ onlyProportionalResize = false;
23794
23796
  itemType = "";
23795
23797
  children = [];
23796
23798
  constructor(board, id = "", defaultItemData, isGroupItem) {
@@ -50160,7 +50162,8 @@ var defaultCardData = {
50160
50162
  itemType: "Card",
50161
50163
  isOpen: false,
50162
50164
  faceUrl: "",
50163
- backsideUrl: ""
50165
+ backsideUrl: "",
50166
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
50164
50167
  };
50165
50168
 
50166
50169
  class Card extends BaseItem {
@@ -50173,9 +50176,13 @@ class Card extends BaseItem {
50173
50176
  backside = null;
50174
50177
  imageToRender = null;
50175
50178
  shouldUseCustomRender = false;
50176
- enableResize = false;
50177
- constructor(board, id = "", urls) {
50179
+ onlyProportionalResize = true;
50180
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
50181
+ constructor(board, id = "", urls, dimensions) {
50178
50182
  super(board, id, defaultCardData);
50183
+ if (dimensions) {
50184
+ this.dimensions = dimensions;
50185
+ }
50179
50186
  if (urls) {
50180
50187
  this.faceUrl = urls.faceUrl;
50181
50188
  this.backsideUrl = urls.backsideUrl;
@@ -50193,6 +50200,9 @@ class Card extends BaseItem {
50193
50200
  });
50194
50201
  this.updateMbr();
50195
50202
  }
50203
+ getDimensions() {
50204
+ return this.dimensions;
50205
+ }
50196
50206
  createImages() {
50197
50207
  this.face = conf.documentFactory.createElement("img");
50198
50208
  this.backside = conf.documentFactory.createElement("img");
@@ -50248,8 +50258,8 @@ class Card extends BaseItem {
50248
50258
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
50249
50259
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
50250
50260
  div.id = this.getId();
50251
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
50252
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
50261
+ div.style.width = `${this.dimensions.width}px`;
50262
+ div.style.height = `${this.dimensions.height}px`;
50253
50263
  div.style.transformOrigin = "top left";
50254
50264
  div.style.transform = transform;
50255
50265
  div.style.position = "absolute";
@@ -50260,8 +50270,8 @@ class Card extends BaseItem {
50260
50270
  updateMbr() {
50261
50271
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
50262
50272
  const rotation = this.transformation.getRotation();
50263
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
50264
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
50273
+ const height3 = this.dimensions.height * scaleY;
50274
+ const width2 = this.dimensions.width * scaleX;
50265
50275
  if (rotation % 180 === 0) {
50266
50276
  this.left = translateX;
50267
50277
  this.top = translateY;
@@ -50402,7 +50412,9 @@ class Deck extends BaseItem {
50402
50412
  childIds.forEach((childId) => {
50403
50413
  const foundItem = this.board.items.getById(childId);
50404
50414
  if (this.parent !== childId && this.getId() !== childId) {
50405
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
50415
+ const firstCard = this.getFirstCard();
50416
+ const firstCardDimensions = firstCard?.getDimensions();
50417
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
50406
50418
  if (canAddItem) {
50407
50419
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
50408
50420
  foundItem.transformation.apply({
@@ -50412,6 +50424,19 @@ class Deck extends BaseItem {
50412
50424
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
50413
50425
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
50414
50426
  });
50427
+ if (firstCard) {
50428
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
50429
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
50430
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
50431
+ foundItem.transformation.apply({
50432
+ class: "Transformation",
50433
+ method: "scaleTo",
50434
+ item: [this.id],
50435
+ x: targetScaleX,
50436
+ y: targetScaleY
50437
+ });
50438
+ }
50439
+ }
50415
50440
  this.board.selection.remove(foundItem);
50416
50441
  this.board.items.index.remove(foundItem);
50417
50442
  foundItem.parent = this.getId();
@@ -50576,6 +50601,9 @@ class Deck extends BaseItem {
50576
50601
  this.isCacheDirty = false;
50577
50602
  this.updateMbr();
50578
50603
  }
50604
+ getFirstCard() {
50605
+ return this.index?.list()[0];
50606
+ }
50579
50607
  }
50580
50608
  registerItem({
50581
50609
  item: Deck,
@@ -54084,7 +54112,7 @@ function transformItems({
54084
54112
  setSnapCursorPos
54085
54113
  }) {
54086
54114
  const items = selection.items.list();
54087
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
54115
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
54088
54116
  if (includesProportionalItem && (isWidth || isHeight)) {
54089
54117
  return null;
54090
54118
  }
@@ -38,6 +38,7 @@ export declare class BaseItem extends Mbr implements Geometry {
38
38
  shouldRenderOutsideViewRect: boolean;
39
39
  shouldUseRelativeAlignment: boolean;
40
40
  enableResize: boolean;
41
+ onlyProportionalResize: boolean;
41
42
  itemType: string;
42
43
  children: string[];
43
44
  constructor(board: Board, id?: string, defaultItemData?: BaseItemData | undefined, isGroupItem?: boolean);
@@ -17,11 +17,22 @@ export declare class Card extends BaseItem {
17
17
  backside: HTMLImageElement | null;
18
18
  private imageToRender;
19
19
  shouldUseCustomRender: boolean;
20
- enableResize: boolean;
20
+ onlyProportionalResize: boolean;
21
+ dimensions: {
22
+ width: number;
23
+ height: number;
24
+ };
21
25
  constructor(board: Board, id?: string, urls?: {
22
26
  faceUrl: string;
23
27
  backsideUrl: string;
28
+ }, dimensions?: {
29
+ width: number;
30
+ height: number;
24
31
  });
32
+ getDimensions(): {
33
+ width: number;
34
+ height: number;
35
+ };
25
36
  createImages(): void;
26
37
  updateImageToRender(): void;
27
38
  getImage(): HTMLImageElement | null;
@@ -31,5 +31,6 @@ export declare class Deck extends BaseItem {
31
31
  render(context: DrawingContext): void;
32
32
  renderHTML(documentFactory: DocumentFactory): HTMLElement;
33
33
  private updateCache;
34
+ getFirstCard(): Card | undefined;
34
35
  }
35
36
  export declare function createDeck(event?: KeyboardEvent, board?: Board): void;
@@ -236,6 +236,10 @@ export declare const conf: {
236
236
  width: number;
237
237
  height: number;
238
238
  };
239
+ DEFAULT_GAME_ITEM_DIMENSIONS: {
240
+ width: number;
241
+ height: number;
242
+ };
239
243
  };
240
244
  export type Settings = typeof conf;
241
245
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.38",
3
+ "version": "0.5.40",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",