microboard-temp 0.5.151 → 0.6.0

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.
@@ -20853,8 +20853,14 @@ class SpatialIndex {
20853
20853
  }
20854
20854
  change = (item) => {
20855
20855
  this.itemsIndex.change(item);
20856
- this.Mbr = new Mbr;
20857
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20856
+ if (this.itemsArray.length === 0) {
20857
+ this.Mbr = new Mbr;
20858
+ } else {
20859
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20860
+ for (let i = 1;i < this.itemsArray.length; i++) {
20861
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20862
+ }
20863
+ }
20858
20864
  this.subject.publish(this.items);
20859
20865
  };
20860
20866
  remove(item) {
@@ -20867,8 +20873,14 @@ class SpatialIndex {
20867
20873
  }
20868
20874
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20869
20875
  this.itemsIndex.remove(item);
20870
- this.Mbr = new Mbr;
20871
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20876
+ if (this.itemsArray.length === 0) {
20877
+ this.Mbr = new Mbr;
20878
+ } else {
20879
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20880
+ for (let i = 1;i < this.itemsArray.length; i++) {
20881
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20882
+ }
20883
+ }
20872
20884
  this.subject.publish(this.items);
20873
20885
  }
20874
20886
  copy() {
@@ -21177,6 +21189,22 @@ class Items {
21177
21189
  getMbr() {
21178
21190
  return this.index.getMbr();
21179
21191
  }
21192
+ getFilteredMbr() {
21193
+ const MAX_ITEM_SIZE = 1e6;
21194
+ const items = this.listAll();
21195
+ let mbr = null;
21196
+ for (const item of items) {
21197
+ const itemMbr = item.getMbr();
21198
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21199
+ if (mbr === null) {
21200
+ mbr = itemMbr.copy();
21201
+ } else {
21202
+ mbr.combine([itemMbr]);
21203
+ }
21204
+ }
21205
+ }
21206
+ return mbr ?? this.getMbr();
21207
+ }
21180
21208
  getInView() {
21181
21209
  const { left, top, right, bottom } = this.view.getMbr();
21182
21210
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -21548,6 +21576,8 @@ class BaseItem extends Mbr {
21548
21576
  onlyProportionalResize = false;
21549
21577
  itemType = "";
21550
21578
  children = [];
21579
+ isHoverHighlighted = false;
21580
+ static HOVER_HIGHLIGHT_COLOR = "rgba(71, 120, 245, 0.7)";
21551
21581
  constructor(board, id = "", defaultItemData, isGroupItem) {
21552
21582
  super();
21553
21583
  this.defaultItemData = defaultItemData;
@@ -21835,10 +21865,24 @@ class BaseItem extends Mbr {
21835
21865
  getPath() {
21836
21866
  return new Path(this.getMbr().getLines(), true);
21837
21867
  }
21868
+ highlightMbr() {
21869
+ this.isHoverHighlighted = true;
21870
+ this.subject.publish(this);
21871
+ }
21872
+ clearHighlightMbr() {
21873
+ this.isHoverHighlighted = false;
21874
+ this.subject.publish(this);
21875
+ }
21838
21876
  render(context) {
21839
21877
  if (this.index) {
21840
21878
  this.index.render(context);
21841
21879
  }
21880
+ if (this.isHoverHighlighted) {
21881
+ const mbr = this.getMbr();
21882
+ mbr.strokeWidth = 2 / context.matrix.scaleX;
21883
+ mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
21884
+ mbr.render(context);
21885
+ }
21842
21886
  }
21843
21887
  renderHTML(documentFactory) {
21844
21888
  const div = documentFactory.createElement("base-item");
@@ -57082,7 +57126,7 @@ function onBoardLoad(board) {
57082
57126
  const hasItemsInBoard = board.items.listAll().length !== 0;
57083
57127
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
57084
57128
  if (isItemsOutOfView && hasItemsInBoard) {
57085
- board.camera.zoomToFit(board.items.getMbr());
57129
+ board.camera.zoomToFit(board.items.getFilteredMbr());
57086
57130
  }
57087
57131
  if (!hasItemsInBoard) {
57088
57132
  board.camera.zoomToViewCenter(1);
package/dist/cjs/index.js CHANGED
@@ -20853,8 +20853,14 @@ class SpatialIndex {
20853
20853
  }
20854
20854
  change = (item) => {
20855
20855
  this.itemsIndex.change(item);
20856
- this.Mbr = new Mbr;
20857
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20856
+ if (this.itemsArray.length === 0) {
20857
+ this.Mbr = new Mbr;
20858
+ } else {
20859
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20860
+ for (let i = 1;i < this.itemsArray.length; i++) {
20861
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20862
+ }
20863
+ }
20858
20864
  this.subject.publish(this.items);
20859
20865
  };
20860
20866
  remove(item) {
@@ -20867,8 +20873,14 @@ class SpatialIndex {
20867
20873
  }
20868
20874
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20869
20875
  this.itemsIndex.remove(item);
20870
- this.Mbr = new Mbr;
20871
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20876
+ if (this.itemsArray.length === 0) {
20877
+ this.Mbr = new Mbr;
20878
+ } else {
20879
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20880
+ for (let i = 1;i < this.itemsArray.length; i++) {
20881
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20882
+ }
20883
+ }
20872
20884
  this.subject.publish(this.items);
20873
20885
  }
20874
20886
  copy() {
@@ -21177,6 +21189,22 @@ class Items {
21177
21189
  getMbr() {
21178
21190
  return this.index.getMbr();
21179
21191
  }
21192
+ getFilteredMbr() {
21193
+ const MAX_ITEM_SIZE = 1e6;
21194
+ const items = this.listAll();
21195
+ let mbr = null;
21196
+ for (const item of items) {
21197
+ const itemMbr = item.getMbr();
21198
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21199
+ if (mbr === null) {
21200
+ mbr = itemMbr.copy();
21201
+ } else {
21202
+ mbr.combine([itemMbr]);
21203
+ }
21204
+ }
21205
+ }
21206
+ return mbr ?? this.getMbr();
21207
+ }
21180
21208
  getInView() {
21181
21209
  const { left, top, right, bottom } = this.view.getMbr();
21182
21210
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -21548,6 +21576,8 @@ class BaseItem extends Mbr {
21548
21576
  onlyProportionalResize = false;
21549
21577
  itemType = "";
21550
21578
  children = [];
21579
+ isHoverHighlighted = false;
21580
+ static HOVER_HIGHLIGHT_COLOR = "rgba(71, 120, 245, 0.7)";
21551
21581
  constructor(board, id = "", defaultItemData, isGroupItem) {
21552
21582
  super();
21553
21583
  this.defaultItemData = defaultItemData;
@@ -21835,10 +21865,24 @@ class BaseItem extends Mbr {
21835
21865
  getPath() {
21836
21866
  return new Path(this.getMbr().getLines(), true);
21837
21867
  }
21868
+ highlightMbr() {
21869
+ this.isHoverHighlighted = true;
21870
+ this.subject.publish(this);
21871
+ }
21872
+ clearHighlightMbr() {
21873
+ this.isHoverHighlighted = false;
21874
+ this.subject.publish(this);
21875
+ }
21838
21876
  render(context) {
21839
21877
  if (this.index) {
21840
21878
  this.index.render(context);
21841
21879
  }
21880
+ if (this.isHoverHighlighted) {
21881
+ const mbr = this.getMbr();
21882
+ mbr.strokeWidth = 2 / context.matrix.scaleX;
21883
+ mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
21884
+ mbr.render(context);
21885
+ }
21842
21886
  }
21843
21887
  renderHTML(documentFactory) {
21844
21888
  const div = documentFactory.createElement("base-item");
@@ -57082,7 +57126,7 @@ function onBoardLoad(board) {
57082
57126
  const hasItemsInBoard = board.items.listAll().length !== 0;
57083
57127
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
57084
57128
  if (isItemsOutOfView && hasItemsInBoard) {
57085
- board.camera.zoomToFit(board.items.getMbr());
57129
+ board.camera.zoomToFit(board.items.getFilteredMbr());
57086
57130
  }
57087
57131
  if (!hasItemsInBoard) {
57088
57132
  board.camera.zoomToViewCenter(1);
package/dist/cjs/node.js CHANGED
@@ -23325,8 +23325,14 @@ class SpatialIndex {
23325
23325
  }
23326
23326
  change = (item) => {
23327
23327
  this.itemsIndex.change(item);
23328
- this.Mbr = new Mbr;
23329
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
23328
+ if (this.itemsArray.length === 0) {
23329
+ this.Mbr = new Mbr;
23330
+ } else {
23331
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23332
+ for (let i = 1;i < this.itemsArray.length; i++) {
23333
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23334
+ }
23335
+ }
23330
23336
  this.subject.publish(this.items);
23331
23337
  };
23332
23338
  remove(item) {
@@ -23339,8 +23345,14 @@ class SpatialIndex {
23339
23345
  }
23340
23346
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
23341
23347
  this.itemsIndex.remove(item);
23342
- this.Mbr = new Mbr;
23343
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
23348
+ if (this.itemsArray.length === 0) {
23349
+ this.Mbr = new Mbr;
23350
+ } else {
23351
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23352
+ for (let i = 1;i < this.itemsArray.length; i++) {
23353
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23354
+ }
23355
+ }
23344
23356
  this.subject.publish(this.items);
23345
23357
  }
23346
23358
  copy() {
@@ -23649,6 +23661,22 @@ class Items {
23649
23661
  getMbr() {
23650
23662
  return this.index.getMbr();
23651
23663
  }
23664
+ getFilteredMbr() {
23665
+ const MAX_ITEM_SIZE = 1e6;
23666
+ const items = this.listAll();
23667
+ let mbr = null;
23668
+ for (const item of items) {
23669
+ const itemMbr = item.getMbr();
23670
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
23671
+ if (mbr === null) {
23672
+ mbr = itemMbr.copy();
23673
+ } else {
23674
+ mbr.combine([itemMbr]);
23675
+ }
23676
+ }
23677
+ }
23678
+ return mbr ?? this.getMbr();
23679
+ }
23652
23680
  getInView() {
23653
23681
  const { left, top, right, bottom } = this.view.getMbr();
23654
23682
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -24020,6 +24048,8 @@ class BaseItem extends Mbr {
24020
24048
  onlyProportionalResize = false;
24021
24049
  itemType = "";
24022
24050
  children = [];
24051
+ isHoverHighlighted = false;
24052
+ static HOVER_HIGHLIGHT_COLOR = "rgba(71, 120, 245, 0.7)";
24023
24053
  constructor(board, id = "", defaultItemData, isGroupItem) {
24024
24054
  super();
24025
24055
  this.defaultItemData = defaultItemData;
@@ -24307,10 +24337,24 @@ class BaseItem extends Mbr {
24307
24337
  getPath() {
24308
24338
  return new Path(this.getMbr().getLines(), true);
24309
24339
  }
24340
+ highlightMbr() {
24341
+ this.isHoverHighlighted = true;
24342
+ this.subject.publish(this);
24343
+ }
24344
+ clearHighlightMbr() {
24345
+ this.isHoverHighlighted = false;
24346
+ this.subject.publish(this);
24347
+ }
24310
24348
  render(context) {
24311
24349
  if (this.index) {
24312
24350
  this.index.render(context);
24313
24351
  }
24352
+ if (this.isHoverHighlighted) {
24353
+ const mbr = this.getMbr();
24354
+ mbr.strokeWidth = 2 / context.matrix.scaleX;
24355
+ mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
24356
+ mbr.render(context);
24357
+ }
24314
24358
  }
24315
24359
  renderHTML(documentFactory) {
24316
24360
  const div = documentFactory.createElement("base-item");
@@ -59555,7 +59599,7 @@ function onBoardLoad(board) {
59555
59599
  const hasItemsInBoard = board.items.listAll().length !== 0;
59556
59600
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
59557
59601
  if (isItemsOutOfView && hasItemsInBoard) {
59558
- board.camera.zoomToFit(board.items.getMbr());
59602
+ board.camera.zoomToFit(board.items.getFilteredMbr());
59559
59603
  }
59560
59604
  if (!hasItemsInBoard) {
59561
59605
  board.camera.zoomToViewCenter(1);
@@ -20696,8 +20696,14 @@ class SpatialIndex {
20696
20696
  }
20697
20697
  change = (item) => {
20698
20698
  this.itemsIndex.change(item);
20699
- this.Mbr = new Mbr;
20700
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20699
+ if (this.itemsArray.length === 0) {
20700
+ this.Mbr = new Mbr;
20701
+ } else {
20702
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20703
+ for (let i = 1;i < this.itemsArray.length; i++) {
20704
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20705
+ }
20706
+ }
20701
20707
  this.subject.publish(this.items);
20702
20708
  };
20703
20709
  remove(item) {
@@ -20710,8 +20716,14 @@ class SpatialIndex {
20710
20716
  }
20711
20717
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20712
20718
  this.itemsIndex.remove(item);
20713
- this.Mbr = new Mbr;
20714
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20719
+ if (this.itemsArray.length === 0) {
20720
+ this.Mbr = new Mbr;
20721
+ } else {
20722
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20723
+ for (let i = 1;i < this.itemsArray.length; i++) {
20724
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20725
+ }
20726
+ }
20715
20727
  this.subject.publish(this.items);
20716
20728
  }
20717
20729
  copy() {
@@ -21020,6 +21032,22 @@ class Items {
21020
21032
  getMbr() {
21021
21033
  return this.index.getMbr();
21022
21034
  }
21035
+ getFilteredMbr() {
21036
+ const MAX_ITEM_SIZE = 1e6;
21037
+ const items = this.listAll();
21038
+ let mbr = null;
21039
+ for (const item of items) {
21040
+ const itemMbr = item.getMbr();
21041
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21042
+ if (mbr === null) {
21043
+ mbr = itemMbr.copy();
21044
+ } else {
21045
+ mbr.combine([itemMbr]);
21046
+ }
21047
+ }
21048
+ }
21049
+ return mbr ?? this.getMbr();
21050
+ }
21023
21051
  getInView() {
21024
21052
  const { left, top, right, bottom } = this.view.getMbr();
21025
21053
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -21391,6 +21419,8 @@ class BaseItem extends Mbr {
21391
21419
  onlyProportionalResize = false;
21392
21420
  itemType = "";
21393
21421
  children = [];
21422
+ isHoverHighlighted = false;
21423
+ static HOVER_HIGHLIGHT_COLOR = "rgba(71, 120, 245, 0.7)";
21394
21424
  constructor(board, id = "", defaultItemData, isGroupItem) {
21395
21425
  super();
21396
21426
  this.defaultItemData = defaultItemData;
@@ -21678,10 +21708,24 @@ class BaseItem extends Mbr {
21678
21708
  getPath() {
21679
21709
  return new Path(this.getMbr().getLines(), true);
21680
21710
  }
21711
+ highlightMbr() {
21712
+ this.isHoverHighlighted = true;
21713
+ this.subject.publish(this);
21714
+ }
21715
+ clearHighlightMbr() {
21716
+ this.isHoverHighlighted = false;
21717
+ this.subject.publish(this);
21718
+ }
21681
21719
  render(context) {
21682
21720
  if (this.index) {
21683
21721
  this.index.render(context);
21684
21722
  }
21723
+ if (this.isHoverHighlighted) {
21724
+ const mbr = this.getMbr();
21725
+ mbr.strokeWidth = 2 / context.matrix.scaleX;
21726
+ mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
21727
+ mbr.render(context);
21728
+ }
21685
21729
  }
21686
21730
  renderHTML(documentFactory) {
21687
21731
  const div = documentFactory.createElement("base-item");
@@ -56925,7 +56969,7 @@ function onBoardLoad(board) {
56925
56969
  const hasItemsInBoard = board.items.listAll().length !== 0;
56926
56970
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
56927
56971
  if (isItemsOutOfView && hasItemsInBoard) {
56928
- board.camera.zoomToFit(board.items.getMbr());
56972
+ board.camera.zoomToFit(board.items.getFilteredMbr());
56929
56973
  }
56930
56974
  if (!hasItemsInBoard) {
56931
56975
  board.camera.zoomToViewCenter(1);
package/dist/esm/index.js CHANGED
@@ -20689,8 +20689,14 @@ class SpatialIndex {
20689
20689
  }
20690
20690
  change = (item) => {
20691
20691
  this.itemsIndex.change(item);
20692
- this.Mbr = new Mbr;
20693
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20692
+ if (this.itemsArray.length === 0) {
20693
+ this.Mbr = new Mbr;
20694
+ } else {
20695
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20696
+ for (let i = 1;i < this.itemsArray.length; i++) {
20697
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20698
+ }
20699
+ }
20694
20700
  this.subject.publish(this.items);
20695
20701
  };
20696
20702
  remove(item) {
@@ -20703,8 +20709,14 @@ class SpatialIndex {
20703
20709
  }
20704
20710
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20705
20711
  this.itemsIndex.remove(item);
20706
- this.Mbr = new Mbr;
20707
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20712
+ if (this.itemsArray.length === 0) {
20713
+ this.Mbr = new Mbr;
20714
+ } else {
20715
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20716
+ for (let i = 1;i < this.itemsArray.length; i++) {
20717
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20718
+ }
20719
+ }
20708
20720
  this.subject.publish(this.items);
20709
20721
  }
20710
20722
  copy() {
@@ -21013,6 +21025,22 @@ class Items {
21013
21025
  getMbr() {
21014
21026
  return this.index.getMbr();
21015
21027
  }
21028
+ getFilteredMbr() {
21029
+ const MAX_ITEM_SIZE = 1e6;
21030
+ const items = this.listAll();
21031
+ let mbr = null;
21032
+ for (const item of items) {
21033
+ const itemMbr = item.getMbr();
21034
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21035
+ if (mbr === null) {
21036
+ mbr = itemMbr.copy();
21037
+ } else {
21038
+ mbr.combine([itemMbr]);
21039
+ }
21040
+ }
21041
+ }
21042
+ return mbr ?? this.getMbr();
21043
+ }
21016
21044
  getInView() {
21017
21045
  const { left, top, right, bottom } = this.view.getMbr();
21018
21046
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -21384,6 +21412,8 @@ class BaseItem extends Mbr {
21384
21412
  onlyProportionalResize = false;
21385
21413
  itemType = "";
21386
21414
  children = [];
21415
+ isHoverHighlighted = false;
21416
+ static HOVER_HIGHLIGHT_COLOR = "rgba(71, 120, 245, 0.7)";
21387
21417
  constructor(board, id = "", defaultItemData, isGroupItem) {
21388
21418
  super();
21389
21419
  this.defaultItemData = defaultItemData;
@@ -21671,10 +21701,24 @@ class BaseItem extends Mbr {
21671
21701
  getPath() {
21672
21702
  return new Path(this.getMbr().getLines(), true);
21673
21703
  }
21704
+ highlightMbr() {
21705
+ this.isHoverHighlighted = true;
21706
+ this.subject.publish(this);
21707
+ }
21708
+ clearHighlightMbr() {
21709
+ this.isHoverHighlighted = false;
21710
+ this.subject.publish(this);
21711
+ }
21674
21712
  render(context) {
21675
21713
  if (this.index) {
21676
21714
  this.index.render(context);
21677
21715
  }
21716
+ if (this.isHoverHighlighted) {
21717
+ const mbr = this.getMbr();
21718
+ mbr.strokeWidth = 2 / context.matrix.scaleX;
21719
+ mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
21720
+ mbr.render(context);
21721
+ }
21678
21722
  }
21679
21723
  renderHTML(documentFactory) {
21680
21724
  const div = documentFactory.createElement("base-item");
@@ -56918,7 +56962,7 @@ function onBoardLoad(board) {
56918
56962
  const hasItemsInBoard = board.items.listAll().length !== 0;
56919
56963
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
56920
56964
  if (isItemsOutOfView && hasItemsInBoard) {
56921
- board.camera.zoomToFit(board.items.getMbr());
56965
+ board.camera.zoomToFit(board.items.getFilteredMbr());
56922
56966
  }
56923
56967
  if (!hasItemsInBoard) {
56924
56968
  board.camera.zoomToViewCenter(1);
package/dist/esm/node.js CHANGED
@@ -23156,8 +23156,14 @@ class SpatialIndex {
23156
23156
  }
23157
23157
  change = (item) => {
23158
23158
  this.itemsIndex.change(item);
23159
- this.Mbr = new Mbr;
23160
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
23159
+ if (this.itemsArray.length === 0) {
23160
+ this.Mbr = new Mbr;
23161
+ } else {
23162
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23163
+ for (let i = 1;i < this.itemsArray.length; i++) {
23164
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23165
+ }
23166
+ }
23161
23167
  this.subject.publish(this.items);
23162
23168
  };
23163
23169
  remove(item) {
@@ -23170,8 +23176,14 @@ class SpatialIndex {
23170
23176
  }
23171
23177
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
23172
23178
  this.itemsIndex.remove(item);
23173
- this.Mbr = new Mbr;
23174
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
23179
+ if (this.itemsArray.length === 0) {
23180
+ this.Mbr = new Mbr;
23181
+ } else {
23182
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23183
+ for (let i = 1;i < this.itemsArray.length; i++) {
23184
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23185
+ }
23186
+ }
23175
23187
  this.subject.publish(this.items);
23176
23188
  }
23177
23189
  copy() {
@@ -23480,6 +23492,22 @@ class Items {
23480
23492
  getMbr() {
23481
23493
  return this.index.getMbr();
23482
23494
  }
23495
+ getFilteredMbr() {
23496
+ const MAX_ITEM_SIZE = 1e6;
23497
+ const items = this.listAll();
23498
+ let mbr = null;
23499
+ for (const item of items) {
23500
+ const itemMbr = item.getMbr();
23501
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
23502
+ if (mbr === null) {
23503
+ mbr = itemMbr.copy();
23504
+ } else {
23505
+ mbr.combine([itemMbr]);
23506
+ }
23507
+ }
23508
+ }
23509
+ return mbr ?? this.getMbr();
23510
+ }
23483
23511
  getInView() {
23484
23512
  const { left, top, right, bottom } = this.view.getMbr();
23485
23513
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -23851,6 +23879,8 @@ class BaseItem extends Mbr {
23851
23879
  onlyProportionalResize = false;
23852
23880
  itemType = "";
23853
23881
  children = [];
23882
+ isHoverHighlighted = false;
23883
+ static HOVER_HIGHLIGHT_COLOR = "rgba(71, 120, 245, 0.7)";
23854
23884
  constructor(board, id = "", defaultItemData, isGroupItem) {
23855
23885
  super();
23856
23886
  this.defaultItemData = defaultItemData;
@@ -24138,10 +24168,24 @@ class BaseItem extends Mbr {
24138
24168
  getPath() {
24139
24169
  return new Path(this.getMbr().getLines(), true);
24140
24170
  }
24171
+ highlightMbr() {
24172
+ this.isHoverHighlighted = true;
24173
+ this.subject.publish(this);
24174
+ }
24175
+ clearHighlightMbr() {
24176
+ this.isHoverHighlighted = false;
24177
+ this.subject.publish(this);
24178
+ }
24141
24179
  render(context) {
24142
24180
  if (this.index) {
24143
24181
  this.index.render(context);
24144
24182
  }
24183
+ if (this.isHoverHighlighted) {
24184
+ const mbr = this.getMbr();
24185
+ mbr.strokeWidth = 2 / context.matrix.scaleX;
24186
+ mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
24187
+ mbr.render(context);
24188
+ }
24145
24189
  }
24146
24190
  renderHTML(documentFactory) {
24147
24191
  const div = documentFactory.createElement("base-item");
@@ -59386,7 +59430,7 @@ function onBoardLoad(board) {
59386
59430
  const hasItemsInBoard = board.items.listAll().length !== 0;
59387
59431
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
59388
59432
  if (isItemsOutOfView && hasItemsInBoard) {
59389
- board.camera.zoomToFit(board.items.getMbr());
59433
+ board.camera.zoomToFit(board.items.getFilteredMbr());
59390
59434
  }
59391
59435
  if (!hasItemsInBoard) {
59392
59436
  board.camera.zoomToViewCenter(1);
@@ -41,6 +41,8 @@ export declare class BaseItem extends Mbr implements Geometry {
41
41
  onlyProportionalResize: boolean;
42
42
  itemType: string;
43
43
  children: string[];
44
+ isHoverHighlighted: boolean;
45
+ static readonly HOVER_HIGHLIGHT_COLOR = "rgba(71, 120, 245, 0.7)";
44
46
  constructor(board: Board, id?: string, defaultItemData?: BaseItemData | undefined, isGroupItem?: boolean);
45
47
  updateChildrenIds(): void;
46
48
  getId(): string;
@@ -77,6 +79,8 @@ export declare class BaseItem extends Mbr implements Geometry {
77
79
  isEnclosedOrCrossedBy(rect: Mbr): boolean;
78
80
  getMbrWithChildren(): Mbr;
79
81
  getPath(): Path | Paths;
82
+ highlightMbr(): void;
83
+ clearHighlightMbr(): void;
80
84
  render(context: DrawingContext): void;
81
85
  renderHTML(documentFactory: DocumentFactory): HTMLElement;
82
86
  }
@@ -62,6 +62,7 @@ export declare class Items {
62
62
  getGroupItemsEnclosedOrCrossed(left: number, top: number, right: number, bottom: number): BaseItem[];
63
63
  getUnderPoint(point: Point, tolerance?: number): Item[];
64
64
  getMbr(): Mbr;
65
+ getFilteredMbr(): Mbr;
65
66
  getInView(): Item[];
66
67
  getItemsInView(): Item[];
67
68
  getGroupItemsInView(): BaseItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.151",
3
+ "version": "0.6.0",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",