microboard-temp 0.4.96 → 0.4.98

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.
@@ -7064,7 +7064,9 @@ var conf = {
7064
7064
  FORCE_HOTKEYS: "auto",
7065
7065
  debug: false,
7066
7066
  FALLBACK_LNG: "en",
7067
- cursorsMap
7067
+ cursorsMap,
7068
+ DECK_HORIZONTAL_OFFSET: 2,
7069
+ DECK_VERTICAL_OFFSET: 0
7068
7070
  };
7069
7071
  initDefaultI18N();
7070
7072
 
@@ -18997,6 +18999,7 @@ class Comment {
18997
18999
  subject = new Subject;
18998
19000
  linkTo;
18999
19001
  transformationRenderBlock = undefined;
19002
+ enableResize = true;
19000
19003
  constructor(anchor = new Point, events, id = "") {
19001
19004
  this.anchor = anchor;
19002
19005
  this.events = events;
@@ -21475,6 +21478,7 @@ class BaseItem extends Mbr {
21475
21478
  shouldUseCustomRender = false;
21476
21479
  shouldRenderOutsideViewRect = true;
21477
21480
  shouldUseRelativeAlignment = true;
21481
+ enableResize = true;
21478
21482
  itemType = "";
21479
21483
  constructor(board, id = "", defaultItemData, isGroupItem) {
21480
21484
  super();
@@ -47825,6 +47829,7 @@ class Card extends BaseItem {
47825
47829
  backside = null;
47826
47830
  imageToRender = null;
47827
47831
  shouldUseCustomRender = false;
47832
+ enableResize = false;
47828
47833
  constructor(board, id = "", urls) {
47829
47834
  super(board, id, defaultCardData);
47830
47835
  if (urls) {
@@ -47863,6 +47868,9 @@ class Card extends BaseItem {
47863
47868
  this.imageToRender = this.face;
47864
47869
  }
47865
47870
  }
47871
+ getImage() {
47872
+ return this.imageToRender;
47873
+ }
47866
47874
  render(context, left, top) {
47867
47875
  if (this.transformationRenderBlock) {
47868
47876
  return;
@@ -47929,6 +47937,7 @@ class Deck extends BaseItem {
47929
47937
  shouldUseCustomRender = false;
47930
47938
  cachedCanvas = null;
47931
47939
  isCacheDirty = true;
47940
+ enableResize = false;
47932
47941
  constructor(board, id = "") {
47933
47942
  super(board, id, defaultDeckData, true);
47934
47943
  this.index.getUnderPoint = () => [];
@@ -47952,8 +47961,8 @@ class Deck extends BaseItem {
47952
47961
  class: "Transformation",
47953
47962
  method: "translateTo",
47954
47963
  item: [this.id],
47955
- x: this.left + (this.index?.list().length || 0) * 2,
47956
- y: this.top
47964
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47965
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47957
47966
  });
47958
47967
  this.board.items.index.remove(foundItem);
47959
47968
  foundItem.parent = this.getId();
@@ -48055,7 +48064,6 @@ class Deck extends BaseItem {
48055
48064
  const ctx = context.ctx;
48056
48065
  if (this.isCacheDirty || !this.cachedCanvas) {
48057
48066
  this.updateCache(context);
48058
- this.isCacheDirty = false;
48059
48067
  }
48060
48068
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48061
48069
  ctx.save();
@@ -48064,9 +48072,12 @@ class Deck extends BaseItem {
48064
48072
  }
48065
48073
  }
48066
48074
  updateCache(context) {
48075
+ const cards = this.index?.list();
48076
+ const topCard = cards[cards.length - 1];
48077
+ const topCardImage = topCard?.getImage();
48067
48078
  const width2 = this.getWidth();
48068
48079
  const height3 = this.getHeight();
48069
- if (!width2 || !height3) {
48080
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
48070
48081
  return;
48071
48082
  }
48072
48083
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -48076,10 +48087,12 @@ class Deck extends BaseItem {
48076
48087
  if (!tempCtx)
48077
48088
  return;
48078
48089
  const tempContext = { ...context, ctx: tempCtx };
48079
- this.index?.list().forEach((item, index2) => {
48080
- item.render(tempContext, index2 * 2, 0);
48090
+ cards.forEach((_, index2) => {
48091
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
48081
48092
  });
48082
48093
  this.cachedCanvas = tempCanvas;
48094
+ this.isCacheDirty = false;
48095
+ this.updateMbr();
48083
48096
  }
48084
48097
  }
48085
48098
  registerItem({
@@ -51617,7 +51630,8 @@ class Transformer extends Tool {
51617
51630
  return false;
51618
51631
  }
51619
51632
  const isLockedItems = this.selection.getIsLockedSelection();
51620
- if (isLockedItems) {
51633
+ const isResizeEnabled = this.selection.getIsResizeEnabled();
51634
+ if (isLockedItems || !isResizeEnabled) {
51621
51635
  return false;
51622
51636
  }
51623
51637
  this.updateAnchorType();
@@ -52860,6 +52874,10 @@ class BoardSelection {
52860
52874
  this.board.tools.getSelect()?.nestingHighlighter.clear();
52861
52875
  this.setContext("None");
52862
52876
  }
52877
+ getIsResizeEnabled() {
52878
+ const items = this.list();
52879
+ return !items.some((item) => !item.enableResize);
52880
+ }
52863
52881
  getIsLockedSelection() {
52864
52882
  const items = this.list();
52865
52883
  return items.some((item) => item.transformation.isLocked);
package/dist/cjs/index.js CHANGED
@@ -7064,7 +7064,9 @@ var conf = {
7064
7064
  FORCE_HOTKEYS: "auto",
7065
7065
  debug: false,
7066
7066
  FALLBACK_LNG: "en",
7067
- cursorsMap
7067
+ cursorsMap,
7068
+ DECK_HORIZONTAL_OFFSET: 2,
7069
+ DECK_VERTICAL_OFFSET: 0
7068
7070
  };
7069
7071
  initDefaultI18N();
7070
7072
 
@@ -18997,6 +18999,7 @@ class Comment {
18997
18999
  subject = new Subject;
18998
19000
  linkTo;
18999
19001
  transformationRenderBlock = undefined;
19002
+ enableResize = true;
19000
19003
  constructor(anchor = new Point, events, id = "") {
19001
19004
  this.anchor = anchor;
19002
19005
  this.events = events;
@@ -21475,6 +21478,7 @@ class BaseItem extends Mbr {
21475
21478
  shouldUseCustomRender = false;
21476
21479
  shouldRenderOutsideViewRect = true;
21477
21480
  shouldUseRelativeAlignment = true;
21481
+ enableResize = true;
21478
21482
  itemType = "";
21479
21483
  constructor(board, id = "", defaultItemData, isGroupItem) {
21480
21484
  super();
@@ -47825,6 +47829,7 @@ class Card extends BaseItem {
47825
47829
  backside = null;
47826
47830
  imageToRender = null;
47827
47831
  shouldUseCustomRender = false;
47832
+ enableResize = false;
47828
47833
  constructor(board, id = "", urls) {
47829
47834
  super(board, id, defaultCardData);
47830
47835
  if (urls) {
@@ -47863,6 +47868,9 @@ class Card extends BaseItem {
47863
47868
  this.imageToRender = this.face;
47864
47869
  }
47865
47870
  }
47871
+ getImage() {
47872
+ return this.imageToRender;
47873
+ }
47866
47874
  render(context, left, top) {
47867
47875
  if (this.transformationRenderBlock) {
47868
47876
  return;
@@ -47929,6 +47937,7 @@ class Deck extends BaseItem {
47929
47937
  shouldUseCustomRender = false;
47930
47938
  cachedCanvas = null;
47931
47939
  isCacheDirty = true;
47940
+ enableResize = false;
47932
47941
  constructor(board, id = "") {
47933
47942
  super(board, id, defaultDeckData, true);
47934
47943
  this.index.getUnderPoint = () => [];
@@ -47952,8 +47961,8 @@ class Deck extends BaseItem {
47952
47961
  class: "Transformation",
47953
47962
  method: "translateTo",
47954
47963
  item: [this.id],
47955
- x: this.left + (this.index?.list().length || 0) * 2,
47956
- y: this.top
47964
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47965
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47957
47966
  });
47958
47967
  this.board.items.index.remove(foundItem);
47959
47968
  foundItem.parent = this.getId();
@@ -48055,7 +48064,6 @@ class Deck extends BaseItem {
48055
48064
  const ctx = context.ctx;
48056
48065
  if (this.isCacheDirty || !this.cachedCanvas) {
48057
48066
  this.updateCache(context);
48058
- this.isCacheDirty = false;
48059
48067
  }
48060
48068
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48061
48069
  ctx.save();
@@ -48064,9 +48072,12 @@ class Deck extends BaseItem {
48064
48072
  }
48065
48073
  }
48066
48074
  updateCache(context) {
48075
+ const cards = this.index?.list();
48076
+ const topCard = cards[cards.length - 1];
48077
+ const topCardImage = topCard?.getImage();
48067
48078
  const width2 = this.getWidth();
48068
48079
  const height3 = this.getHeight();
48069
- if (!width2 || !height3) {
48080
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
48070
48081
  return;
48071
48082
  }
48072
48083
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -48076,10 +48087,12 @@ class Deck extends BaseItem {
48076
48087
  if (!tempCtx)
48077
48088
  return;
48078
48089
  const tempContext = { ...context, ctx: tempCtx };
48079
- this.index?.list().forEach((item, index2) => {
48080
- item.render(tempContext, index2 * 2, 0);
48090
+ cards.forEach((_, index2) => {
48091
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
48081
48092
  });
48082
48093
  this.cachedCanvas = tempCanvas;
48094
+ this.isCacheDirty = false;
48095
+ this.updateMbr();
48083
48096
  }
48084
48097
  }
48085
48098
  registerItem({
@@ -51617,7 +51630,8 @@ class Transformer extends Tool {
51617
51630
  return false;
51618
51631
  }
51619
51632
  const isLockedItems = this.selection.getIsLockedSelection();
51620
- if (isLockedItems) {
51633
+ const isResizeEnabled = this.selection.getIsResizeEnabled();
51634
+ if (isLockedItems || !isResizeEnabled) {
51621
51635
  return false;
51622
51636
  }
51623
51637
  this.updateAnchorType();
@@ -52860,6 +52874,10 @@ class BoardSelection {
52860
52874
  this.board.tools.getSelect()?.nestingHighlighter.clear();
52861
52875
  this.setContext("None");
52862
52876
  }
52877
+ getIsResizeEnabled() {
52878
+ const items = this.list();
52879
+ return !items.some((item) => !item.enableResize);
52880
+ }
52863
52881
  getIsLockedSelection() {
52864
52882
  const items = this.list();
52865
52883
  return items.some((item) => item.transformation.isLocked);
package/dist/cjs/node.js CHANGED
@@ -8101,7 +8101,9 @@ var conf = {
8101
8101
  FORCE_HOTKEYS: "auto",
8102
8102
  debug: false,
8103
8103
  FALLBACK_LNG: "en",
8104
- cursorsMap
8104
+ cursorsMap,
8105
+ DECK_HORIZONTAL_OFFSET: 2,
8106
+ DECK_VERTICAL_OFFSET: 0
8105
8107
  };
8106
8108
  initDefaultI18N();
8107
8109
 
@@ -21536,6 +21538,7 @@ class Comment {
21536
21538
  subject = new Subject;
21537
21539
  linkTo;
21538
21540
  transformationRenderBlock = undefined;
21541
+ enableResize = true;
21539
21542
  constructor(anchor = new Point, events, id = "") {
21540
21543
  this.anchor = anchor;
21541
21544
  this.events = events;
@@ -23947,6 +23950,7 @@ class BaseItem extends Mbr {
23947
23950
  shouldUseCustomRender = false;
23948
23951
  shouldRenderOutsideViewRect = true;
23949
23952
  shouldUseRelativeAlignment = true;
23953
+ enableResize = true;
23950
23954
  itemType = "";
23951
23955
  constructor(board, id = "", defaultItemData, isGroupItem) {
23952
23956
  super();
@@ -50298,6 +50302,7 @@ class Card extends BaseItem {
50298
50302
  backside = null;
50299
50303
  imageToRender = null;
50300
50304
  shouldUseCustomRender = false;
50305
+ enableResize = false;
50301
50306
  constructor(board, id = "", urls) {
50302
50307
  super(board, id, defaultCardData);
50303
50308
  if (urls) {
@@ -50336,6 +50341,9 @@ class Card extends BaseItem {
50336
50341
  this.imageToRender = this.face;
50337
50342
  }
50338
50343
  }
50344
+ getImage() {
50345
+ return this.imageToRender;
50346
+ }
50339
50347
  render(context, left, top) {
50340
50348
  if (this.transformationRenderBlock) {
50341
50349
  return;
@@ -50402,6 +50410,7 @@ class Deck extends BaseItem {
50402
50410
  shouldUseCustomRender = false;
50403
50411
  cachedCanvas = null;
50404
50412
  isCacheDirty = true;
50413
+ enableResize = false;
50405
50414
  constructor(board, id = "") {
50406
50415
  super(board, id, defaultDeckData, true);
50407
50416
  this.index.getUnderPoint = () => [];
@@ -50425,8 +50434,8 @@ class Deck extends BaseItem {
50425
50434
  class: "Transformation",
50426
50435
  method: "translateTo",
50427
50436
  item: [this.id],
50428
- x: this.left + (this.index?.list().length || 0) * 2,
50429
- y: this.top
50437
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
50438
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
50430
50439
  });
50431
50440
  this.board.items.index.remove(foundItem);
50432
50441
  foundItem.parent = this.getId();
@@ -50528,7 +50537,6 @@ class Deck extends BaseItem {
50528
50537
  const ctx = context.ctx;
50529
50538
  if (this.isCacheDirty || !this.cachedCanvas) {
50530
50539
  this.updateCache(context);
50531
- this.isCacheDirty = false;
50532
50540
  }
50533
50541
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50534
50542
  ctx.save();
@@ -50537,9 +50545,12 @@ class Deck extends BaseItem {
50537
50545
  }
50538
50546
  }
50539
50547
  updateCache(context) {
50548
+ const cards = this.index?.list();
50549
+ const topCard = cards[cards.length - 1];
50550
+ const topCardImage = topCard?.getImage();
50540
50551
  const width2 = this.getWidth();
50541
50552
  const height3 = this.getHeight();
50542
- if (!width2 || !height3) {
50553
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
50543
50554
  return;
50544
50555
  }
50545
50556
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -50549,10 +50560,12 @@ class Deck extends BaseItem {
50549
50560
  if (!tempCtx)
50550
50561
  return;
50551
50562
  const tempContext = { ...context, ctx: tempCtx };
50552
- this.index?.list().forEach((item, index2) => {
50553
- item.render(tempContext, index2 * 2, 0);
50563
+ cards.forEach((_, index2) => {
50564
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
50554
50565
  });
50555
50566
  this.cachedCanvas = tempCanvas;
50567
+ this.isCacheDirty = false;
50568
+ this.updateMbr();
50556
50569
  }
50557
50570
  }
50558
50571
  registerItem({
@@ -54090,7 +54103,8 @@ class Transformer extends Tool {
54090
54103
  return false;
54091
54104
  }
54092
54105
  const isLockedItems = this.selection.getIsLockedSelection();
54093
- if (isLockedItems) {
54106
+ const isResizeEnabled = this.selection.getIsResizeEnabled();
54107
+ if (isLockedItems || !isResizeEnabled) {
54094
54108
  return false;
54095
54109
  }
54096
54110
  this.updateAnchorType();
@@ -55333,6 +55347,10 @@ class BoardSelection {
55333
55347
  this.board.tools.getSelect()?.nestingHighlighter.clear();
55334
55348
  this.setContext("None");
55335
55349
  }
55350
+ getIsResizeEnabled() {
55351
+ const items = this.list();
55352
+ return !items.some((item) => !item.enableResize);
55353
+ }
55336
55354
  getIsLockedSelection() {
55337
55355
  const items = this.list();
55338
55356
  return items.some((item) => item.transformation.isLocked);
@@ -6904,7 +6904,9 @@ var conf = {
6904
6904
  FORCE_HOTKEYS: "auto",
6905
6905
  debug: false,
6906
6906
  FALLBACK_LNG: "en",
6907
- cursorsMap
6907
+ cursorsMap,
6908
+ DECK_HORIZONTAL_OFFSET: 2,
6909
+ DECK_VERTICAL_OFFSET: 0
6908
6910
  };
6909
6911
  initDefaultI18N();
6910
6912
 
@@ -18846,6 +18848,7 @@ class Comment {
18846
18848
  subject = new Subject;
18847
18849
  linkTo;
18848
18850
  transformationRenderBlock = undefined;
18851
+ enableResize = true;
18849
18852
  constructor(anchor = new Point, events, id = "") {
18850
18853
  this.anchor = anchor;
18851
18854
  this.events = events;
@@ -21324,6 +21327,7 @@ class BaseItem extends Mbr {
21324
21327
  shouldUseCustomRender = false;
21325
21328
  shouldRenderOutsideViewRect = true;
21326
21329
  shouldUseRelativeAlignment = true;
21330
+ enableResize = true;
21327
21331
  itemType = "";
21328
21332
  constructor(board, id = "", defaultItemData, isGroupItem) {
21329
21333
  super();
@@ -47674,6 +47678,7 @@ class Card extends BaseItem {
47674
47678
  backside = null;
47675
47679
  imageToRender = null;
47676
47680
  shouldUseCustomRender = false;
47681
+ enableResize = false;
47677
47682
  constructor(board, id = "", urls) {
47678
47683
  super(board, id, defaultCardData);
47679
47684
  if (urls) {
@@ -47712,6 +47717,9 @@ class Card extends BaseItem {
47712
47717
  this.imageToRender = this.face;
47713
47718
  }
47714
47719
  }
47720
+ getImage() {
47721
+ return this.imageToRender;
47722
+ }
47715
47723
  render(context, left, top) {
47716
47724
  if (this.transformationRenderBlock) {
47717
47725
  return;
@@ -47778,6 +47786,7 @@ class Deck extends BaseItem {
47778
47786
  shouldUseCustomRender = false;
47779
47787
  cachedCanvas = null;
47780
47788
  isCacheDirty = true;
47789
+ enableResize = false;
47781
47790
  constructor(board, id = "") {
47782
47791
  super(board, id, defaultDeckData, true);
47783
47792
  this.index.getUnderPoint = () => [];
@@ -47801,8 +47810,8 @@ class Deck extends BaseItem {
47801
47810
  class: "Transformation",
47802
47811
  method: "translateTo",
47803
47812
  item: [this.id],
47804
- x: this.left + (this.index?.list().length || 0) * 2,
47805
- y: this.top
47813
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47814
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47806
47815
  });
47807
47816
  this.board.items.index.remove(foundItem);
47808
47817
  foundItem.parent = this.getId();
@@ -47904,7 +47913,6 @@ class Deck extends BaseItem {
47904
47913
  const ctx = context.ctx;
47905
47914
  if (this.isCacheDirty || !this.cachedCanvas) {
47906
47915
  this.updateCache(context);
47907
- this.isCacheDirty = false;
47908
47916
  }
47909
47917
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
47910
47918
  ctx.save();
@@ -47913,9 +47921,12 @@ class Deck extends BaseItem {
47913
47921
  }
47914
47922
  }
47915
47923
  updateCache(context) {
47924
+ const cards = this.index?.list();
47925
+ const topCard = cards[cards.length - 1];
47926
+ const topCardImage = topCard?.getImage();
47916
47927
  const width2 = this.getWidth();
47917
47928
  const height3 = this.getHeight();
47918
- if (!width2 || !height3) {
47929
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
47919
47930
  return;
47920
47931
  }
47921
47932
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -47925,10 +47936,12 @@ class Deck extends BaseItem {
47925
47936
  if (!tempCtx)
47926
47937
  return;
47927
47938
  const tempContext = { ...context, ctx: tempCtx };
47928
- this.index?.list().forEach((item, index2) => {
47929
- item.render(tempContext, index2 * 2, 0);
47939
+ cards.forEach((_, index2) => {
47940
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
47930
47941
  });
47931
47942
  this.cachedCanvas = tempCanvas;
47943
+ this.isCacheDirty = false;
47944
+ this.updateMbr();
47932
47945
  }
47933
47946
  }
47934
47947
  registerItem({
@@ -51466,7 +51479,8 @@ class Transformer extends Tool {
51466
51479
  return false;
51467
51480
  }
51468
51481
  const isLockedItems = this.selection.getIsLockedSelection();
51469
- if (isLockedItems) {
51482
+ const isResizeEnabled = this.selection.getIsResizeEnabled();
51483
+ if (isLockedItems || !isResizeEnabled) {
51470
51484
  return false;
51471
51485
  }
51472
51486
  this.updateAnchorType();
@@ -52709,6 +52723,10 @@ class BoardSelection {
52709
52723
  this.board.tools.getSelect()?.nestingHighlighter.clear();
52710
52724
  this.setContext("None");
52711
52725
  }
52726
+ getIsResizeEnabled() {
52727
+ const items = this.list();
52728
+ return !items.some((item) => !item.enableResize);
52729
+ }
52712
52730
  getIsLockedSelection() {
52713
52731
  const items = this.list();
52714
52732
  return items.some((item) => item.transformation.isLocked);
package/dist/esm/index.js CHANGED
@@ -6897,7 +6897,9 @@ var conf = {
6897
6897
  FORCE_HOTKEYS: "auto",
6898
6898
  debug: false,
6899
6899
  FALLBACK_LNG: "en",
6900
- cursorsMap
6900
+ cursorsMap,
6901
+ DECK_HORIZONTAL_OFFSET: 2,
6902
+ DECK_VERTICAL_OFFSET: 0
6901
6903
  };
6902
6904
  initDefaultI18N();
6903
6905
 
@@ -18839,6 +18841,7 @@ class Comment {
18839
18841
  subject = new Subject;
18840
18842
  linkTo;
18841
18843
  transformationRenderBlock = undefined;
18844
+ enableResize = true;
18842
18845
  constructor(anchor = new Point, events, id = "") {
18843
18846
  this.anchor = anchor;
18844
18847
  this.events = events;
@@ -21317,6 +21320,7 @@ class BaseItem extends Mbr {
21317
21320
  shouldUseCustomRender = false;
21318
21321
  shouldRenderOutsideViewRect = true;
21319
21322
  shouldUseRelativeAlignment = true;
21323
+ enableResize = true;
21320
21324
  itemType = "";
21321
21325
  constructor(board, id = "", defaultItemData, isGroupItem) {
21322
21326
  super();
@@ -47667,6 +47671,7 @@ class Card extends BaseItem {
47667
47671
  backside = null;
47668
47672
  imageToRender = null;
47669
47673
  shouldUseCustomRender = false;
47674
+ enableResize = false;
47670
47675
  constructor(board, id = "", urls) {
47671
47676
  super(board, id, defaultCardData);
47672
47677
  if (urls) {
@@ -47705,6 +47710,9 @@ class Card extends BaseItem {
47705
47710
  this.imageToRender = this.face;
47706
47711
  }
47707
47712
  }
47713
+ getImage() {
47714
+ return this.imageToRender;
47715
+ }
47708
47716
  render(context, left, top) {
47709
47717
  if (this.transformationRenderBlock) {
47710
47718
  return;
@@ -47771,6 +47779,7 @@ class Deck extends BaseItem {
47771
47779
  shouldUseCustomRender = false;
47772
47780
  cachedCanvas = null;
47773
47781
  isCacheDirty = true;
47782
+ enableResize = false;
47774
47783
  constructor(board, id = "") {
47775
47784
  super(board, id, defaultDeckData, true);
47776
47785
  this.index.getUnderPoint = () => [];
@@ -47794,8 +47803,8 @@ class Deck extends BaseItem {
47794
47803
  class: "Transformation",
47795
47804
  method: "translateTo",
47796
47805
  item: [this.id],
47797
- x: this.left + (this.index?.list().length || 0) * 2,
47798
- y: this.top
47806
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
47807
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
47799
47808
  });
47800
47809
  this.board.items.index.remove(foundItem);
47801
47810
  foundItem.parent = this.getId();
@@ -47897,7 +47906,6 @@ class Deck extends BaseItem {
47897
47906
  const ctx = context.ctx;
47898
47907
  if (this.isCacheDirty || !this.cachedCanvas) {
47899
47908
  this.updateCache(context);
47900
- this.isCacheDirty = false;
47901
47909
  }
47902
47910
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
47903
47911
  ctx.save();
@@ -47906,9 +47914,12 @@ class Deck extends BaseItem {
47906
47914
  }
47907
47915
  }
47908
47916
  updateCache(context) {
47917
+ const cards = this.index?.list();
47918
+ const topCard = cards[cards.length - 1];
47919
+ const topCardImage = topCard?.getImage();
47909
47920
  const width2 = this.getWidth();
47910
47921
  const height3 = this.getHeight();
47911
- if (!width2 || !height3) {
47922
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
47912
47923
  return;
47913
47924
  }
47914
47925
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -47918,10 +47929,12 @@ class Deck extends BaseItem {
47918
47929
  if (!tempCtx)
47919
47930
  return;
47920
47931
  const tempContext = { ...context, ctx: tempCtx };
47921
- this.index?.list().forEach((item, index2) => {
47922
- item.render(tempContext, index2 * 2, 0);
47932
+ cards.forEach((_, index2) => {
47933
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
47923
47934
  });
47924
47935
  this.cachedCanvas = tempCanvas;
47936
+ this.isCacheDirty = false;
47937
+ this.updateMbr();
47925
47938
  }
47926
47939
  }
47927
47940
  registerItem({
@@ -51459,7 +51472,8 @@ class Transformer extends Tool {
51459
51472
  return false;
51460
51473
  }
51461
51474
  const isLockedItems = this.selection.getIsLockedSelection();
51462
- if (isLockedItems) {
51475
+ const isResizeEnabled = this.selection.getIsResizeEnabled();
51476
+ if (isLockedItems || !isResizeEnabled) {
51463
51477
  return false;
51464
51478
  }
51465
51479
  this.updateAnchorType();
@@ -52702,6 +52716,10 @@ class BoardSelection {
52702
52716
  this.board.tools.getSelect()?.nestingHighlighter.clear();
52703
52717
  this.setContext("None");
52704
52718
  }
52719
+ getIsResizeEnabled() {
52720
+ const items = this.list();
52721
+ return !items.some((item) => !item.enableResize);
52722
+ }
52705
52723
  getIsLockedSelection() {
52706
52724
  const items = this.list();
52707
52725
  return items.some((item) => item.transformation.isLocked);
package/dist/esm/node.js CHANGED
@@ -7681,7 +7681,9 @@ var conf = {
7681
7681
  FORCE_HOTKEYS: "auto",
7682
7682
  debug: false,
7683
7683
  FALLBACK_LNG: "en",
7684
- cursorsMap
7684
+ cursorsMap,
7685
+ DECK_HORIZONTAL_OFFSET: 2,
7686
+ DECK_VERTICAL_OFFSET: 0
7685
7687
  };
7686
7688
  initDefaultI18N();
7687
7689
 
@@ -21373,6 +21375,7 @@ class Comment {
21373
21375
  subject = new Subject;
21374
21376
  linkTo;
21375
21377
  transformationRenderBlock = undefined;
21378
+ enableResize = true;
21376
21379
  constructor(anchor = new Point, events, id = "") {
21377
21380
  this.anchor = anchor;
21378
21381
  this.events = events;
@@ -23784,6 +23787,7 @@ class BaseItem extends Mbr {
23784
23787
  shouldUseCustomRender = false;
23785
23788
  shouldRenderOutsideViewRect = true;
23786
23789
  shouldUseRelativeAlignment = true;
23790
+ enableResize = true;
23787
23791
  itemType = "";
23788
23792
  constructor(board, id = "", defaultItemData, isGroupItem) {
23789
23793
  super();
@@ -50135,6 +50139,7 @@ class Card extends BaseItem {
50135
50139
  backside = null;
50136
50140
  imageToRender = null;
50137
50141
  shouldUseCustomRender = false;
50142
+ enableResize = false;
50138
50143
  constructor(board, id = "", urls) {
50139
50144
  super(board, id, defaultCardData);
50140
50145
  if (urls) {
@@ -50173,6 +50178,9 @@ class Card extends BaseItem {
50173
50178
  this.imageToRender = this.face;
50174
50179
  }
50175
50180
  }
50181
+ getImage() {
50182
+ return this.imageToRender;
50183
+ }
50176
50184
  render(context, left, top) {
50177
50185
  if (this.transformationRenderBlock) {
50178
50186
  return;
@@ -50239,6 +50247,7 @@ class Deck extends BaseItem {
50239
50247
  shouldUseCustomRender = false;
50240
50248
  cachedCanvas = null;
50241
50249
  isCacheDirty = true;
50250
+ enableResize = false;
50242
50251
  constructor(board, id = "") {
50243
50252
  super(board, id, defaultDeckData, true);
50244
50253
  this.index.getUnderPoint = () => [];
@@ -50262,8 +50271,8 @@ class Deck extends BaseItem {
50262
50271
  class: "Transformation",
50263
50272
  method: "translateTo",
50264
50273
  item: [this.id],
50265
- x: this.left + (this.index?.list().length || 0) * 2,
50266
- y: this.top
50274
+ x: this.left + (this.index?.list().length || 0) * conf.DECK_HORIZONTAL_OFFSET,
50275
+ y: this.top - (this.index?.list().length || 0) * conf.DECK_VERTICAL_OFFSET
50267
50276
  });
50268
50277
  this.board.items.index.remove(foundItem);
50269
50278
  foundItem.parent = this.getId();
@@ -50365,7 +50374,6 @@ class Deck extends BaseItem {
50365
50374
  const ctx = context.ctx;
50366
50375
  if (this.isCacheDirty || !this.cachedCanvas) {
50367
50376
  this.updateCache(context);
50368
- this.isCacheDirty = false;
50369
50377
  }
50370
50378
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50371
50379
  ctx.save();
@@ -50374,9 +50382,12 @@ class Deck extends BaseItem {
50374
50382
  }
50375
50383
  }
50376
50384
  updateCache(context) {
50385
+ const cards = this.index?.list();
50386
+ const topCard = cards[cards.length - 1];
50387
+ const topCardImage = topCard?.getImage();
50377
50388
  const width2 = this.getWidth();
50378
50389
  const height3 = this.getHeight();
50379
- if (!width2 || !height3) {
50390
+ if (!width2 || !height3 || !topCardImage || !topCardImage.complete) {
50380
50391
  return;
50381
50392
  }
50382
50393
  const tempCanvas = conf.documentFactory.createElement("canvas");
@@ -50386,10 +50397,12 @@ class Deck extends BaseItem {
50386
50397
  if (!tempCtx)
50387
50398
  return;
50388
50399
  const tempContext = { ...context, ctx: tempCtx };
50389
- this.index?.list().forEach((item, index2) => {
50390
- item.render(tempContext, index2 * 2, 0);
50400
+ cards.forEach((_, index2) => {
50401
+ topCard.render(tempContext, index2 * conf.DECK_HORIZONTAL_OFFSET, index2 * conf.DECK_VERTICAL_OFFSET);
50391
50402
  });
50392
50403
  this.cachedCanvas = tempCanvas;
50404
+ this.isCacheDirty = false;
50405
+ this.updateMbr();
50393
50406
  }
50394
50407
  }
50395
50408
  registerItem({
@@ -53927,7 +53940,8 @@ class Transformer extends Tool {
53927
53940
  return false;
53928
53941
  }
53929
53942
  const isLockedItems = this.selection.getIsLockedSelection();
53930
- if (isLockedItems) {
53943
+ const isResizeEnabled = this.selection.getIsResizeEnabled();
53944
+ if (isLockedItems || !isResizeEnabled) {
53931
53945
  return false;
53932
53946
  }
53933
53947
  this.updateAnchorType();
@@ -55170,6 +55184,10 @@ class BoardSelection {
55170
55184
  this.board.tools.getSelect()?.nestingHighlighter.clear();
55171
55185
  this.setContext("None");
55172
55186
  }
55187
+ getIsResizeEnabled() {
55188
+ const items = this.list();
55189
+ return !items.some((item) => !item.enableResize);
55190
+ }
55173
55191
  getIsLockedSelection() {
55174
55192
  const items = this.list();
55175
55193
  return items.some((item) => item.transformation.isLocked);
@@ -37,6 +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
41
  itemType: string;
41
42
  constructor(board: Board, id?: string, defaultItemData?: BaseItemData | undefined, isGroupItem?: boolean);
42
43
  getId(): string;
@@ -47,6 +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
51
  constructor(anchor?: Point, events?: Events | undefined, id?: string);
51
52
  serialize(): CommentData;
52
53
  deserialize(data: CommentData): this;
@@ -20,12 +20,14 @@ export declare class Card extends BaseItem {
20
20
  backside: HTMLImageElement | null;
21
21
  private imageToRender;
22
22
  shouldUseCustomRender: boolean;
23
+ enableResize: boolean;
23
24
  constructor(board: Board, id?: string, urls?: {
24
25
  faceUrl: string;
25
26
  backsideUrl: string;
26
27
  });
27
28
  createImages(): void;
28
29
  updateImageToRender(): void;
30
+ getImage(): HTMLImageElement | null;
29
31
  render(context: DrawingContext, left?: number, top?: number): void;
30
32
  updateMbr(): void;
31
33
  getPath(): Path | Paths;
@@ -10,6 +10,7 @@ export declare class Deck extends BaseItem {
10
10
  shouldUseCustomRender: boolean;
11
11
  private cachedCanvas;
12
12
  private isCacheDirty;
13
+ enableResize: boolean;
13
14
  constructor(board: Board, id?: string);
14
15
  applyAddChildren(childIds: string[]): void;
15
16
  applyRemoveChildren(childIds: string[]): void;
@@ -131,6 +131,7 @@ export declare class BoardSelection {
131
131
  setHorisontalAlignment(horisontalAlignment: HorisontalAlignment): void;
132
132
  setVerticalAlignment(verticalAlignment: VerticalAlignment): void;
133
133
  removeFromBoard(): void;
134
+ getIsResizeEnabled(): boolean;
134
135
  getIsLockedSelection(): boolean;
135
136
  isLocked(): boolean;
136
137
  lock(): void;
@@ -230,6 +230,8 @@ export declare const conf: {
230
230
  debug: boolean;
231
231
  FALLBACK_LNG: string;
232
232
  cursorsMap: Partial<Record<import("./Pointer/Cursor").CursorName, string>>;
233
+ DECK_HORIZONTAL_OFFSET: number;
234
+ DECK_VERTICAL_OFFSET: number;
233
235
  };
234
236
  export type Settings = typeof conf;
235
237
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.4.96",
3
+ "version": "0.4.98",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",