microboard-temp 0.5.39 → 0.5.41

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.
@@ -18996,7 +18996,7 @@ class Comment {
18996
18996
  subject = new Subject;
18997
18997
  linkTo;
18998
18998
  transformationRenderBlock = undefined;
18999
- enableResize = true;
18999
+ resizeEnabled = true;
19000
19000
  constructor(anchor = new Point, events, id = "") {
19001
19001
  this.anchor = anchor;
19002
19002
  this.events = events;
@@ -21485,7 +21485,7 @@ class BaseItem extends Mbr {
21485
21485
  shouldUseCustomRender = false;
21486
21486
  shouldRenderOutsideViewRect = true;
21487
21487
  shouldUseRelativeAlignment = true;
21488
- enableResize = true;
21488
+ resizeEnabled = true;
21489
21489
  onlyProportionalResize = false;
21490
21490
  itemType = "";
21491
21491
  children = [];
@@ -21677,6 +21677,50 @@ class BaseItem extends Mbr {
21677
21677
  command.apply();
21678
21678
  this.board.events.emit(operation, command);
21679
21679
  }
21680
+ disableResize(items) {
21681
+ const itemsMap = {};
21682
+ items.forEach((item) => {
21683
+ if (!item.resizeEnabled) {
21684
+ return;
21685
+ }
21686
+ if (itemsMap[item.itemType]) {
21687
+ itemsMap[item.itemType].push(item.getId());
21688
+ } else {
21689
+ itemsMap[item.itemType] = [item.getId()];
21690
+ }
21691
+ });
21692
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21693
+ this.emitForManyItems({
21694
+ class: itemType,
21695
+ method: "toggleResizeEnabled",
21696
+ item: itemIds,
21697
+ newData: { resizeEnabled: false },
21698
+ prevData: { resizeEnabled: true }
21699
+ });
21700
+ });
21701
+ }
21702
+ enableResize(items) {
21703
+ const itemsMap = {};
21704
+ items.forEach((item) => {
21705
+ if (item.resizeEnabled) {
21706
+ return;
21707
+ }
21708
+ if (itemsMap[item.itemType]) {
21709
+ itemsMap[item.itemType].push(item.getId());
21710
+ } else {
21711
+ itemsMap[item.itemType] = [item.getId()];
21712
+ }
21713
+ });
21714
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21715
+ this.emitForManyItems({
21716
+ class: itemType,
21717
+ method: "toggleResizeEnabled",
21718
+ item: itemIds,
21719
+ newData: { resizeEnabled: true },
21720
+ prevData: { resizeEnabled: false }
21721
+ });
21722
+ });
21723
+ }
21680
21724
  apply(op) {
21681
21725
  op = op;
21682
21726
  switch (op.class) {
@@ -21695,6 +21739,9 @@ class BaseItem extends Mbr {
21695
21739
  case "addChildren":
21696
21740
  this.applyAddChildren(op.newData.childIds);
21697
21741
  break;
21742
+ case "toggleResizeEnabled":
21743
+ this.resizeEnabled = op.newData.resizeEnabled;
21744
+ break;
21698
21745
  }
21699
21746
  }
21700
21747
  }
@@ -47893,6 +47940,9 @@ class Card extends BaseItem {
47893
47940
  });
47894
47941
  this.updateMbr();
47895
47942
  }
47943
+ getDimensions() {
47944
+ return this.dimensions;
47945
+ }
47896
47946
  createImages() {
47897
47947
  this.face = conf.documentFactory.createElement("img");
47898
47948
  this.backside = conf.documentFactory.createElement("img");
@@ -48078,7 +48128,7 @@ class Deck extends BaseItem {
48078
48128
  shouldUseCustomRender = false;
48079
48129
  cachedCanvas = null;
48080
48130
  isCacheDirty = true;
48081
- enableResize = false;
48131
+ resizeEnabled = false;
48082
48132
  path = null;
48083
48133
  isPerpendicular = undefined;
48084
48134
  constructor(board, id = "") {
@@ -48102,7 +48152,9 @@ class Deck extends BaseItem {
48102
48152
  childIds.forEach((childId) => {
48103
48153
  const foundItem = this.board.items.getById(childId);
48104
48154
  if (this.parent !== childId && this.getId() !== childId) {
48105
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
48155
+ const firstCard = this.getFirstCard();
48156
+ const firstCardDimensions = firstCard?.getDimensions();
48157
+ 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);
48106
48158
  if (canAddItem) {
48107
48159
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
48108
48160
  foundItem.transformation.apply({
@@ -48112,6 +48164,19 @@ class Deck extends BaseItem {
48112
48164
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
48113
48165
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
48114
48166
  });
48167
+ if (firstCard) {
48168
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
48169
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
48170
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
48171
+ foundItem.transformation.apply({
48172
+ class: "Transformation",
48173
+ method: "scaleTo",
48174
+ item: [this.id],
48175
+ x: targetScaleX,
48176
+ y: targetScaleY
48177
+ });
48178
+ }
48179
+ }
48115
48180
  this.board.selection.remove(foundItem);
48116
48181
  this.board.items.index.remove(foundItem);
48117
48182
  foundItem.parent = this.getId();
@@ -48276,6 +48341,9 @@ class Deck extends BaseItem {
48276
48341
  this.isCacheDirty = false;
48277
48342
  this.updateMbr();
48278
48343
  }
48344
+ getFirstCard() {
48345
+ return this.index?.list()[0];
48346
+ }
48279
48347
  }
48280
48348
  registerItem({
48281
48349
  item: Deck,
@@ -53277,7 +53345,7 @@ class BoardSelection {
53277
53345
  }
53278
53346
  getIsResizeEnabled() {
53279
53347
  const items = this.list();
53280
- return !items.some((item) => !item.enableResize);
53348
+ return !items.some((item) => !item.resizeEnabled);
53281
53349
  }
53282
53350
  getIsLockedSelection() {
53283
53351
  const items = this.list();
package/dist/cjs/index.js CHANGED
@@ -18996,7 +18996,7 @@ class Comment {
18996
18996
  subject = new Subject;
18997
18997
  linkTo;
18998
18998
  transformationRenderBlock = undefined;
18999
- enableResize = true;
18999
+ resizeEnabled = true;
19000
19000
  constructor(anchor = new Point, events, id = "") {
19001
19001
  this.anchor = anchor;
19002
19002
  this.events = events;
@@ -21485,7 +21485,7 @@ class BaseItem extends Mbr {
21485
21485
  shouldUseCustomRender = false;
21486
21486
  shouldRenderOutsideViewRect = true;
21487
21487
  shouldUseRelativeAlignment = true;
21488
- enableResize = true;
21488
+ resizeEnabled = true;
21489
21489
  onlyProportionalResize = false;
21490
21490
  itemType = "";
21491
21491
  children = [];
@@ -21677,6 +21677,50 @@ class BaseItem extends Mbr {
21677
21677
  command.apply();
21678
21678
  this.board.events.emit(operation, command);
21679
21679
  }
21680
+ disableResize(items) {
21681
+ const itemsMap = {};
21682
+ items.forEach((item) => {
21683
+ if (!item.resizeEnabled) {
21684
+ return;
21685
+ }
21686
+ if (itemsMap[item.itemType]) {
21687
+ itemsMap[item.itemType].push(item.getId());
21688
+ } else {
21689
+ itemsMap[item.itemType] = [item.getId()];
21690
+ }
21691
+ });
21692
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21693
+ this.emitForManyItems({
21694
+ class: itemType,
21695
+ method: "toggleResizeEnabled",
21696
+ item: itemIds,
21697
+ newData: { resizeEnabled: false },
21698
+ prevData: { resizeEnabled: true }
21699
+ });
21700
+ });
21701
+ }
21702
+ enableResize(items) {
21703
+ const itemsMap = {};
21704
+ items.forEach((item) => {
21705
+ if (item.resizeEnabled) {
21706
+ return;
21707
+ }
21708
+ if (itemsMap[item.itemType]) {
21709
+ itemsMap[item.itemType].push(item.getId());
21710
+ } else {
21711
+ itemsMap[item.itemType] = [item.getId()];
21712
+ }
21713
+ });
21714
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21715
+ this.emitForManyItems({
21716
+ class: itemType,
21717
+ method: "toggleResizeEnabled",
21718
+ item: itemIds,
21719
+ newData: { resizeEnabled: true },
21720
+ prevData: { resizeEnabled: false }
21721
+ });
21722
+ });
21723
+ }
21680
21724
  apply(op) {
21681
21725
  op = op;
21682
21726
  switch (op.class) {
@@ -21695,6 +21739,9 @@ class BaseItem extends Mbr {
21695
21739
  case "addChildren":
21696
21740
  this.applyAddChildren(op.newData.childIds);
21697
21741
  break;
21742
+ case "toggleResizeEnabled":
21743
+ this.resizeEnabled = op.newData.resizeEnabled;
21744
+ break;
21698
21745
  }
21699
21746
  }
21700
21747
  }
@@ -47893,6 +47940,9 @@ class Card extends BaseItem {
47893
47940
  });
47894
47941
  this.updateMbr();
47895
47942
  }
47943
+ getDimensions() {
47944
+ return this.dimensions;
47945
+ }
47896
47946
  createImages() {
47897
47947
  this.face = conf.documentFactory.createElement("img");
47898
47948
  this.backside = conf.documentFactory.createElement("img");
@@ -48078,7 +48128,7 @@ class Deck extends BaseItem {
48078
48128
  shouldUseCustomRender = false;
48079
48129
  cachedCanvas = null;
48080
48130
  isCacheDirty = true;
48081
- enableResize = false;
48131
+ resizeEnabled = false;
48082
48132
  path = null;
48083
48133
  isPerpendicular = undefined;
48084
48134
  constructor(board, id = "") {
@@ -48102,7 +48152,9 @@ class Deck extends BaseItem {
48102
48152
  childIds.forEach((childId) => {
48103
48153
  const foundItem = this.board.items.getById(childId);
48104
48154
  if (this.parent !== childId && this.getId() !== childId) {
48105
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
48155
+ const firstCard = this.getFirstCard();
48156
+ const firstCardDimensions = firstCard?.getDimensions();
48157
+ 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);
48106
48158
  if (canAddItem) {
48107
48159
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
48108
48160
  foundItem.transformation.apply({
@@ -48112,6 +48164,19 @@ class Deck extends BaseItem {
48112
48164
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
48113
48165
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
48114
48166
  });
48167
+ if (firstCard) {
48168
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
48169
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
48170
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
48171
+ foundItem.transformation.apply({
48172
+ class: "Transformation",
48173
+ method: "scaleTo",
48174
+ item: [this.id],
48175
+ x: targetScaleX,
48176
+ y: targetScaleY
48177
+ });
48178
+ }
48179
+ }
48115
48180
  this.board.selection.remove(foundItem);
48116
48181
  this.board.items.index.remove(foundItem);
48117
48182
  foundItem.parent = this.getId();
@@ -48276,6 +48341,9 @@ class Deck extends BaseItem {
48276
48341
  this.isCacheDirty = false;
48277
48342
  this.updateMbr();
48278
48343
  }
48344
+ getFirstCard() {
48345
+ return this.index?.list()[0];
48346
+ }
48279
48347
  }
48280
48348
  registerItem({
48281
48349
  item: Deck,
@@ -53277,7 +53345,7 @@ class BoardSelection {
53277
53345
  }
53278
53346
  getIsResizeEnabled() {
53279
53347
  const items = this.list();
53280
- return !items.some((item) => !item.enableResize);
53348
+ return !items.some((item) => !item.resizeEnabled);
53281
53349
  }
53282
53350
  getIsLockedSelection() {
53283
53351
  const items = this.list();
package/dist/cjs/node.js CHANGED
@@ -21535,7 +21535,7 @@ class Comment {
21535
21535
  subject = new Subject;
21536
21536
  linkTo;
21537
21537
  transformationRenderBlock = undefined;
21538
- enableResize = true;
21538
+ resizeEnabled = true;
21539
21539
  constructor(anchor = new Point, events, id = "") {
21540
21540
  this.anchor = anchor;
21541
21541
  this.events = events;
@@ -23957,7 +23957,7 @@ class BaseItem extends Mbr {
23957
23957
  shouldUseCustomRender = false;
23958
23958
  shouldRenderOutsideViewRect = true;
23959
23959
  shouldUseRelativeAlignment = true;
23960
- enableResize = true;
23960
+ resizeEnabled = true;
23961
23961
  onlyProportionalResize = false;
23962
23962
  itemType = "";
23963
23963
  children = [];
@@ -24149,6 +24149,50 @@ class BaseItem extends Mbr {
24149
24149
  command.apply();
24150
24150
  this.board.events.emit(operation, command);
24151
24151
  }
24152
+ disableResize(items) {
24153
+ const itemsMap = {};
24154
+ items.forEach((item) => {
24155
+ if (!item.resizeEnabled) {
24156
+ return;
24157
+ }
24158
+ if (itemsMap[item.itemType]) {
24159
+ itemsMap[item.itemType].push(item.getId());
24160
+ } else {
24161
+ itemsMap[item.itemType] = [item.getId()];
24162
+ }
24163
+ });
24164
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
24165
+ this.emitForManyItems({
24166
+ class: itemType,
24167
+ method: "toggleResizeEnabled",
24168
+ item: itemIds,
24169
+ newData: { resizeEnabled: false },
24170
+ prevData: { resizeEnabled: true }
24171
+ });
24172
+ });
24173
+ }
24174
+ enableResize(items) {
24175
+ const itemsMap = {};
24176
+ items.forEach((item) => {
24177
+ if (item.resizeEnabled) {
24178
+ return;
24179
+ }
24180
+ if (itemsMap[item.itemType]) {
24181
+ itemsMap[item.itemType].push(item.getId());
24182
+ } else {
24183
+ itemsMap[item.itemType] = [item.getId()];
24184
+ }
24185
+ });
24186
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
24187
+ this.emitForManyItems({
24188
+ class: itemType,
24189
+ method: "toggleResizeEnabled",
24190
+ item: itemIds,
24191
+ newData: { resizeEnabled: true },
24192
+ prevData: { resizeEnabled: false }
24193
+ });
24194
+ });
24195
+ }
24152
24196
  apply(op) {
24153
24197
  op = op;
24154
24198
  switch (op.class) {
@@ -24167,6 +24211,9 @@ class BaseItem extends Mbr {
24167
24211
  case "addChildren":
24168
24212
  this.applyAddChildren(op.newData.childIds);
24169
24213
  break;
24214
+ case "toggleResizeEnabled":
24215
+ this.resizeEnabled = op.newData.resizeEnabled;
24216
+ break;
24170
24217
  }
24171
24218
  }
24172
24219
  }
@@ -50366,6 +50413,9 @@ class Card extends BaseItem {
50366
50413
  });
50367
50414
  this.updateMbr();
50368
50415
  }
50416
+ getDimensions() {
50417
+ return this.dimensions;
50418
+ }
50369
50419
  createImages() {
50370
50420
  this.face = conf.documentFactory.createElement("img");
50371
50421
  this.backside = conf.documentFactory.createElement("img");
@@ -50551,7 +50601,7 @@ class Deck extends BaseItem {
50551
50601
  shouldUseCustomRender = false;
50552
50602
  cachedCanvas = null;
50553
50603
  isCacheDirty = true;
50554
- enableResize = false;
50604
+ resizeEnabled = false;
50555
50605
  path = null;
50556
50606
  isPerpendicular = undefined;
50557
50607
  constructor(board, id = "") {
@@ -50575,7 +50625,9 @@ class Deck extends BaseItem {
50575
50625
  childIds.forEach((childId) => {
50576
50626
  const foundItem = this.board.items.getById(childId);
50577
50627
  if (this.parent !== childId && this.getId() !== childId) {
50578
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
50628
+ const firstCard = this.getFirstCard();
50629
+ const firstCardDimensions = firstCard?.getDimensions();
50630
+ 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);
50579
50631
  if (canAddItem) {
50580
50632
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
50581
50633
  foundItem.transformation.apply({
@@ -50585,6 +50637,19 @@ class Deck extends BaseItem {
50585
50637
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
50586
50638
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
50587
50639
  });
50640
+ if (firstCard) {
50641
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
50642
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
50643
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
50644
+ foundItem.transformation.apply({
50645
+ class: "Transformation",
50646
+ method: "scaleTo",
50647
+ item: [this.id],
50648
+ x: targetScaleX,
50649
+ y: targetScaleY
50650
+ });
50651
+ }
50652
+ }
50588
50653
  this.board.selection.remove(foundItem);
50589
50654
  this.board.items.index.remove(foundItem);
50590
50655
  foundItem.parent = this.getId();
@@ -50749,6 +50814,9 @@ class Deck extends BaseItem {
50749
50814
  this.isCacheDirty = false;
50750
50815
  this.updateMbr();
50751
50816
  }
50817
+ getFirstCard() {
50818
+ return this.index?.list()[0];
50819
+ }
50752
50820
  }
50753
50821
  registerItem({
50754
50822
  item: Deck,
@@ -55750,7 +55818,7 @@ class BoardSelection {
55750
55818
  }
55751
55819
  getIsResizeEnabled() {
55752
55820
  const items = this.list();
55753
- return !items.some((item) => !item.enableResize);
55821
+ return !items.some((item) => !item.resizeEnabled);
55754
55822
  }
55755
55823
  getIsLockedSelection() {
55756
55824
  const items = this.list();
@@ -18842,7 +18842,7 @@ class Comment {
18842
18842
  subject = new Subject;
18843
18843
  linkTo;
18844
18844
  transformationRenderBlock = undefined;
18845
- enableResize = true;
18845
+ resizeEnabled = true;
18846
18846
  constructor(anchor = new Point, events, id = "") {
18847
18847
  this.anchor = anchor;
18848
18848
  this.events = events;
@@ -21331,7 +21331,7 @@ class BaseItem extends Mbr {
21331
21331
  shouldUseCustomRender = false;
21332
21332
  shouldRenderOutsideViewRect = true;
21333
21333
  shouldUseRelativeAlignment = true;
21334
- enableResize = true;
21334
+ resizeEnabled = true;
21335
21335
  onlyProportionalResize = false;
21336
21336
  itemType = "";
21337
21337
  children = [];
@@ -21523,6 +21523,50 @@ class BaseItem extends Mbr {
21523
21523
  command.apply();
21524
21524
  this.board.events.emit(operation, command);
21525
21525
  }
21526
+ disableResize(items) {
21527
+ const itemsMap = {};
21528
+ items.forEach((item) => {
21529
+ if (!item.resizeEnabled) {
21530
+ return;
21531
+ }
21532
+ if (itemsMap[item.itemType]) {
21533
+ itemsMap[item.itemType].push(item.getId());
21534
+ } else {
21535
+ itemsMap[item.itemType] = [item.getId()];
21536
+ }
21537
+ });
21538
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21539
+ this.emitForManyItems({
21540
+ class: itemType,
21541
+ method: "toggleResizeEnabled",
21542
+ item: itemIds,
21543
+ newData: { resizeEnabled: false },
21544
+ prevData: { resizeEnabled: true }
21545
+ });
21546
+ });
21547
+ }
21548
+ enableResize(items) {
21549
+ const itemsMap = {};
21550
+ items.forEach((item) => {
21551
+ if (item.resizeEnabled) {
21552
+ return;
21553
+ }
21554
+ if (itemsMap[item.itemType]) {
21555
+ itemsMap[item.itemType].push(item.getId());
21556
+ } else {
21557
+ itemsMap[item.itemType] = [item.getId()];
21558
+ }
21559
+ });
21560
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21561
+ this.emitForManyItems({
21562
+ class: itemType,
21563
+ method: "toggleResizeEnabled",
21564
+ item: itemIds,
21565
+ newData: { resizeEnabled: true },
21566
+ prevData: { resizeEnabled: false }
21567
+ });
21568
+ });
21569
+ }
21526
21570
  apply(op) {
21527
21571
  op = op;
21528
21572
  switch (op.class) {
@@ -21541,6 +21585,9 @@ class BaseItem extends Mbr {
21541
21585
  case "addChildren":
21542
21586
  this.applyAddChildren(op.newData.childIds);
21543
21587
  break;
21588
+ case "toggleResizeEnabled":
21589
+ this.resizeEnabled = op.newData.resizeEnabled;
21590
+ break;
21544
21591
  }
21545
21592
  }
21546
21593
  }
@@ -47739,6 +47786,9 @@ class Card extends BaseItem {
47739
47786
  });
47740
47787
  this.updateMbr();
47741
47788
  }
47789
+ getDimensions() {
47790
+ return this.dimensions;
47791
+ }
47742
47792
  createImages() {
47743
47793
  this.face = conf.documentFactory.createElement("img");
47744
47794
  this.backside = conf.documentFactory.createElement("img");
@@ -47924,7 +47974,7 @@ class Deck extends BaseItem {
47924
47974
  shouldUseCustomRender = false;
47925
47975
  cachedCanvas = null;
47926
47976
  isCacheDirty = true;
47927
- enableResize = false;
47977
+ resizeEnabled = false;
47928
47978
  path = null;
47929
47979
  isPerpendicular = undefined;
47930
47980
  constructor(board, id = "") {
@@ -47948,7 +47998,9 @@ class Deck extends BaseItem {
47948
47998
  childIds.forEach((childId) => {
47949
47999
  const foundItem = this.board.items.getById(childId);
47950
48000
  if (this.parent !== childId && this.getId() !== childId) {
47951
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
48001
+ const firstCard = this.getFirstCard();
48002
+ const firstCardDimensions = firstCard?.getDimensions();
48003
+ 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);
47952
48004
  if (canAddItem) {
47953
48005
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
47954
48006
  foundItem.transformation.apply({
@@ -47958,6 +48010,19 @@ class Deck extends BaseItem {
47958
48010
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
47959
48011
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
47960
48012
  });
48013
+ if (firstCard) {
48014
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
48015
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
48016
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
48017
+ foundItem.transformation.apply({
48018
+ class: "Transformation",
48019
+ method: "scaleTo",
48020
+ item: [this.id],
48021
+ x: targetScaleX,
48022
+ y: targetScaleY
48023
+ });
48024
+ }
48025
+ }
47961
48026
  this.board.selection.remove(foundItem);
47962
48027
  this.board.items.index.remove(foundItem);
47963
48028
  foundItem.parent = this.getId();
@@ -48122,6 +48187,9 @@ class Deck extends BaseItem {
48122
48187
  this.isCacheDirty = false;
48123
48188
  this.updateMbr();
48124
48189
  }
48190
+ getFirstCard() {
48191
+ return this.index?.list()[0];
48192
+ }
48125
48193
  }
48126
48194
  registerItem({
48127
48195
  item: Deck,
@@ -53123,7 +53191,7 @@ class BoardSelection {
53123
53191
  }
53124
53192
  getIsResizeEnabled() {
53125
53193
  const items = this.list();
53126
- return !items.some((item) => !item.enableResize);
53194
+ return !items.some((item) => !item.resizeEnabled);
53127
53195
  }
53128
53196
  getIsLockedSelection() {
53129
53197
  const items = this.list();
package/dist/esm/index.js CHANGED
@@ -18835,7 +18835,7 @@ class Comment {
18835
18835
  subject = new Subject;
18836
18836
  linkTo;
18837
18837
  transformationRenderBlock = undefined;
18838
- enableResize = true;
18838
+ resizeEnabled = true;
18839
18839
  constructor(anchor = new Point, events, id = "") {
18840
18840
  this.anchor = anchor;
18841
18841
  this.events = events;
@@ -21324,7 +21324,7 @@ class BaseItem extends Mbr {
21324
21324
  shouldUseCustomRender = false;
21325
21325
  shouldRenderOutsideViewRect = true;
21326
21326
  shouldUseRelativeAlignment = true;
21327
- enableResize = true;
21327
+ resizeEnabled = true;
21328
21328
  onlyProportionalResize = false;
21329
21329
  itemType = "";
21330
21330
  children = [];
@@ -21516,6 +21516,50 @@ class BaseItem extends Mbr {
21516
21516
  command.apply();
21517
21517
  this.board.events.emit(operation, command);
21518
21518
  }
21519
+ disableResize(items) {
21520
+ const itemsMap = {};
21521
+ items.forEach((item) => {
21522
+ if (!item.resizeEnabled) {
21523
+ return;
21524
+ }
21525
+ if (itemsMap[item.itemType]) {
21526
+ itemsMap[item.itemType].push(item.getId());
21527
+ } else {
21528
+ itemsMap[item.itemType] = [item.getId()];
21529
+ }
21530
+ });
21531
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21532
+ this.emitForManyItems({
21533
+ class: itemType,
21534
+ method: "toggleResizeEnabled",
21535
+ item: itemIds,
21536
+ newData: { resizeEnabled: false },
21537
+ prevData: { resizeEnabled: true }
21538
+ });
21539
+ });
21540
+ }
21541
+ enableResize(items) {
21542
+ const itemsMap = {};
21543
+ items.forEach((item) => {
21544
+ if (item.resizeEnabled) {
21545
+ return;
21546
+ }
21547
+ if (itemsMap[item.itemType]) {
21548
+ itemsMap[item.itemType].push(item.getId());
21549
+ } else {
21550
+ itemsMap[item.itemType] = [item.getId()];
21551
+ }
21552
+ });
21553
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
21554
+ this.emitForManyItems({
21555
+ class: itemType,
21556
+ method: "toggleResizeEnabled",
21557
+ item: itemIds,
21558
+ newData: { resizeEnabled: true },
21559
+ prevData: { resizeEnabled: false }
21560
+ });
21561
+ });
21562
+ }
21519
21563
  apply(op) {
21520
21564
  op = op;
21521
21565
  switch (op.class) {
@@ -21534,6 +21578,9 @@ class BaseItem extends Mbr {
21534
21578
  case "addChildren":
21535
21579
  this.applyAddChildren(op.newData.childIds);
21536
21580
  break;
21581
+ case "toggleResizeEnabled":
21582
+ this.resizeEnabled = op.newData.resizeEnabled;
21583
+ break;
21537
21584
  }
21538
21585
  }
21539
21586
  }
@@ -47732,6 +47779,9 @@ class Card extends BaseItem {
47732
47779
  });
47733
47780
  this.updateMbr();
47734
47781
  }
47782
+ getDimensions() {
47783
+ return this.dimensions;
47784
+ }
47735
47785
  createImages() {
47736
47786
  this.face = conf.documentFactory.createElement("img");
47737
47787
  this.backside = conf.documentFactory.createElement("img");
@@ -47917,7 +47967,7 @@ class Deck extends BaseItem {
47917
47967
  shouldUseCustomRender = false;
47918
47968
  cachedCanvas = null;
47919
47969
  isCacheDirty = true;
47920
- enableResize = false;
47970
+ resizeEnabled = false;
47921
47971
  path = null;
47922
47972
  isPerpendicular = undefined;
47923
47973
  constructor(board, id = "") {
@@ -47941,7 +47991,9 @@ class Deck extends BaseItem {
47941
47991
  childIds.forEach((childId) => {
47942
47992
  const foundItem = this.board.items.getById(childId);
47943
47993
  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());
47994
+ const firstCard = this.getFirstCard();
47995
+ const firstCardDimensions = firstCard?.getDimensions();
47996
+ 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
47997
  if (canAddItem) {
47946
47998
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
47947
47999
  foundItem.transformation.apply({
@@ -47951,6 +48003,19 @@ class Deck extends BaseItem {
47951
48003
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
47952
48004
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
47953
48005
  });
48006
+ if (firstCard) {
48007
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
48008
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
48009
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
48010
+ foundItem.transformation.apply({
48011
+ class: "Transformation",
48012
+ method: "scaleTo",
48013
+ item: [this.id],
48014
+ x: targetScaleX,
48015
+ y: targetScaleY
48016
+ });
48017
+ }
48018
+ }
47954
48019
  this.board.selection.remove(foundItem);
47955
48020
  this.board.items.index.remove(foundItem);
47956
48021
  foundItem.parent = this.getId();
@@ -48115,6 +48180,9 @@ class Deck extends BaseItem {
48115
48180
  this.isCacheDirty = false;
48116
48181
  this.updateMbr();
48117
48182
  }
48183
+ getFirstCard() {
48184
+ return this.index?.list()[0];
48185
+ }
48118
48186
  }
48119
48187
  registerItem({
48120
48188
  item: Deck,
@@ -53116,7 +53184,7 @@ class BoardSelection {
53116
53184
  }
53117
53185
  getIsResizeEnabled() {
53118
53186
  const items = this.list();
53119
- return !items.some((item) => !item.enableResize);
53187
+ return !items.some((item) => !item.resizeEnabled);
53120
53188
  }
53121
53189
  getIsLockedSelection() {
53122
53190
  const items = this.list();
package/dist/esm/node.js CHANGED
@@ -21369,7 +21369,7 @@ class Comment {
21369
21369
  subject = new Subject;
21370
21370
  linkTo;
21371
21371
  transformationRenderBlock = undefined;
21372
- enableResize = true;
21372
+ resizeEnabled = true;
21373
21373
  constructor(anchor = new Point, events, id = "") {
21374
21374
  this.anchor = anchor;
21375
21375
  this.events = events;
@@ -23791,7 +23791,7 @@ class BaseItem extends Mbr {
23791
23791
  shouldUseCustomRender = false;
23792
23792
  shouldRenderOutsideViewRect = true;
23793
23793
  shouldUseRelativeAlignment = true;
23794
- enableResize = true;
23794
+ resizeEnabled = true;
23795
23795
  onlyProportionalResize = false;
23796
23796
  itemType = "";
23797
23797
  children = [];
@@ -23983,6 +23983,50 @@ class BaseItem extends Mbr {
23983
23983
  command.apply();
23984
23984
  this.board.events.emit(operation, command);
23985
23985
  }
23986
+ disableResize(items) {
23987
+ const itemsMap = {};
23988
+ items.forEach((item) => {
23989
+ if (!item.resizeEnabled) {
23990
+ return;
23991
+ }
23992
+ if (itemsMap[item.itemType]) {
23993
+ itemsMap[item.itemType].push(item.getId());
23994
+ } else {
23995
+ itemsMap[item.itemType] = [item.getId()];
23996
+ }
23997
+ });
23998
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
23999
+ this.emitForManyItems({
24000
+ class: itemType,
24001
+ method: "toggleResizeEnabled",
24002
+ item: itemIds,
24003
+ newData: { resizeEnabled: false },
24004
+ prevData: { resizeEnabled: true }
24005
+ });
24006
+ });
24007
+ }
24008
+ enableResize(items) {
24009
+ const itemsMap = {};
24010
+ items.forEach((item) => {
24011
+ if (item.resizeEnabled) {
24012
+ return;
24013
+ }
24014
+ if (itemsMap[item.itemType]) {
24015
+ itemsMap[item.itemType].push(item.getId());
24016
+ } else {
24017
+ itemsMap[item.itemType] = [item.getId()];
24018
+ }
24019
+ });
24020
+ Object.entries(itemsMap).forEach(([itemType, itemIds]) => {
24021
+ this.emitForManyItems({
24022
+ class: itemType,
24023
+ method: "toggleResizeEnabled",
24024
+ item: itemIds,
24025
+ newData: { resizeEnabled: true },
24026
+ prevData: { resizeEnabled: false }
24027
+ });
24028
+ });
24029
+ }
23986
24030
  apply(op) {
23987
24031
  op = op;
23988
24032
  switch (op.class) {
@@ -24001,6 +24045,9 @@ class BaseItem extends Mbr {
24001
24045
  case "addChildren":
24002
24046
  this.applyAddChildren(op.newData.childIds);
24003
24047
  break;
24048
+ case "toggleResizeEnabled":
24049
+ this.resizeEnabled = op.newData.resizeEnabled;
24050
+ break;
24004
24051
  }
24005
24052
  }
24006
24053
  }
@@ -50200,6 +50247,9 @@ class Card extends BaseItem {
50200
50247
  });
50201
50248
  this.updateMbr();
50202
50249
  }
50250
+ getDimensions() {
50251
+ return this.dimensions;
50252
+ }
50203
50253
  createImages() {
50204
50254
  this.face = conf.documentFactory.createElement("img");
50205
50255
  this.backside = conf.documentFactory.createElement("img");
@@ -50385,7 +50435,7 @@ class Deck extends BaseItem {
50385
50435
  shouldUseCustomRender = false;
50386
50436
  cachedCanvas = null;
50387
50437
  isCacheDirty = true;
50388
- enableResize = false;
50438
+ resizeEnabled = false;
50389
50439
  path = null;
50390
50440
  isPerpendicular = undefined;
50391
50441
  constructor(board, id = "") {
@@ -50409,7 +50459,9 @@ class Deck extends BaseItem {
50409
50459
  childIds.forEach((childId) => {
50410
50460
  const foundItem = this.board.items.getById(childId);
50411
50461
  if (this.parent !== childId && this.getId() !== childId) {
50412
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
50462
+ const firstCard = this.getFirstCard();
50463
+ const firstCardDimensions = firstCard?.getDimensions();
50464
+ 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);
50413
50465
  if (canAddItem) {
50414
50466
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
50415
50467
  foundItem.transformation.apply({
@@ -50419,6 +50471,19 @@ class Deck extends BaseItem {
50419
50471
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
50420
50472
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
50421
50473
  });
50474
+ if (firstCard) {
50475
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
50476
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
50477
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
50478
+ foundItem.transformation.apply({
50479
+ class: "Transformation",
50480
+ method: "scaleTo",
50481
+ item: [this.id],
50482
+ x: targetScaleX,
50483
+ y: targetScaleY
50484
+ });
50485
+ }
50486
+ }
50422
50487
  this.board.selection.remove(foundItem);
50423
50488
  this.board.items.index.remove(foundItem);
50424
50489
  foundItem.parent = this.getId();
@@ -50583,6 +50648,9 @@ class Deck extends BaseItem {
50583
50648
  this.isCacheDirty = false;
50584
50649
  this.updateMbr();
50585
50650
  }
50651
+ getFirstCard() {
50652
+ return this.index?.list()[0];
50653
+ }
50586
50654
  }
50587
50655
  registerItem({
50588
50656
  item: Deck,
@@ -55584,7 +55652,7 @@ class BoardSelection {
55584
55652
  }
55585
55653
  getIsResizeEnabled() {
55586
55654
  const items = this.list();
55587
- return !items.some((item) => !item.enableResize);
55655
+ return !items.some((item) => !item.resizeEnabled);
55588
55656
  }
55589
55657
  getIsLockedSelection() {
55590
55658
  const items = this.list();
@@ -37,7 +37,7 @@ export declare class BaseItem extends Mbr implements Geometry {
37
37
  shouldUseCustomRender: boolean;
38
38
  shouldRenderOutsideViewRect: boolean;
39
39
  shouldUseRelativeAlignment: boolean;
40
- enableResize: boolean;
40
+ resizeEnabled: boolean;
41
41
  onlyProportionalResize: boolean;
42
42
  itemType: string;
43
43
  children: string[];
@@ -65,6 +65,8 @@ export declare class BaseItem extends Mbr implements Geometry {
65
65
  isClosed(): boolean;
66
66
  emit(operation: Operation | BaseOperation): void;
67
67
  emitForManyItems(operation: Operation | BaseOperation): void;
68
+ disableResize(items: BaseItem[]): void;
69
+ enableResize(items: BaseItem[]): void;
68
70
  apply(op: Operation | BaseItemOperation | BaseOperation): void;
69
71
  addOnRemoveCallback(cb: () => void): void;
70
72
  onRemove(): void;
@@ -1,5 +1,5 @@
1
1
  import { BaseOperation } from "../../Events/EventsOperations";
2
- export type BaseItemOperation = RemoveChildren | AddChildren;
2
+ export type BaseItemOperation = RemoveChildren | AddChildren | ToggleResizeEnabled;
3
3
  export interface RemoveChildren extends BaseOperation<{
4
4
  childIds: string[];
5
5
  }> {
@@ -10,3 +10,8 @@ export interface AddChildren extends BaseOperation<{
10
10
  }> {
11
11
  method: "addChildren";
12
12
  }
13
+ export interface ToggleResizeEnabled extends BaseOperation<{
14
+ resizeEnabled: boolean;
15
+ }> {
16
+ method: "toggleResizeEnabled";
17
+ }
@@ -47,7 +47,7 @@ export declare class Comment implements Geometry {
47
47
  readonly subject: Subject<Comment>;
48
48
  readonly linkTo: LinkTo;
49
49
  transformationRenderBlock?: boolean;
50
- enableResize: boolean;
50
+ resizeEnabled: boolean;
51
51
  constructor(anchor?: Point, events?: Events | undefined, id?: string);
52
52
  serialize(): CommentData;
53
53
  deserialize(data: CommentData): this;
@@ -29,6 +29,10 @@ export declare class Card extends BaseItem {
29
29
  width: number;
30
30
  height: number;
31
31
  });
32
+ getDimensions(): {
33
+ width: number;
34
+ height: number;
35
+ };
32
36
  createImages(): void;
33
37
  updateImageToRender(): void;
34
38
  getImage(): HTMLImageElement | null;
@@ -12,7 +12,7 @@ export declare class Deck extends BaseItem {
12
12
  shouldUseCustomRender: boolean;
13
13
  private cachedCanvas;
14
14
  private isCacheDirty;
15
- enableResize: boolean;
15
+ resizeEnabled: boolean;
16
16
  path: Path | null;
17
17
  private isPerpendicular;
18
18
  constructor(board: Board, id?: string);
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.39",
3
+ "version": "0.5.41",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",