microboard-temp 0.4.62 → 0.4.64

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.
@@ -18822,35 +18822,10 @@ class FrameCommand {
18822
18822
  };
18823
18823
  });
18824
18824
  case "addChildren":
18825
- return mapItemsByOperation(frame, (item) => {
18826
- return {
18827
- ...this.operation,
18828
- newData: { childIds: item.getChildrenIds() }
18829
- };
18830
- });
18831
18825
  case "removeChildren":
18832
18826
  return mapItemsByOperation(frame, (item) => {
18833
18827
  return {
18834
- ...this.operation,
18835
- newData: { childIds: item.getChildrenIds() }
18836
- };
18837
- });
18838
- default:
18839
- return mapItemsByOperation(frame, (item) => {
18840
- const op = this.operation;
18841
- let newData = {};
18842
- if (op.prevData) {
18843
- newData = { ...op.prevData };
18844
- } else {
18845
- Object.keys(op.newData).forEach((key) => {
18846
- if (item[key]) {
18847
- newData[key] = item[key];
18848
- }
18849
- });
18850
- }
18851
- return {
18852
- ...op,
18853
- newData
18828
+ ...this.operation
18854
18829
  };
18855
18830
  });
18856
18831
  }
@@ -20832,6 +20807,11 @@ class SpatialIndex {
20832
20807
  return this.getById(item.parent);
20833
20808
  }
20834
20809
  moveToZIndex(item, zIndex) {
20810
+ if (item.parent !== "Board") {
20811
+ this.getById(item.parent)?.index?.moveToZIndex(item, zIndex);
20812
+ this.subject.publish(this.items);
20813
+ return;
20814
+ }
20835
20815
  const index2 = this.itemsArray.indexOf(item);
20836
20816
  this.itemsArray.splice(index2, 1);
20837
20817
  this.itemsArray.splice(zIndex, 0, item);
@@ -20848,6 +20828,13 @@ class SpatialIndex {
20848
20828
  this.itemsArray.forEach(this.change.bind(this));
20849
20829
  }
20850
20830
  sendToBack(item, shouldPublish = true) {
20831
+ if (item.parent !== "Board") {
20832
+ this.getById(item.parent)?.index?.sendToBack(item);
20833
+ if (shouldPublish) {
20834
+ this.subject.publish(this.items);
20835
+ }
20836
+ return;
20837
+ }
20851
20838
  const index2 = this.itemsArray.indexOf(item);
20852
20839
  this.itemsArray.splice(index2, 1);
20853
20840
  this.itemsArray.unshift(item);
@@ -20857,16 +20844,31 @@ class SpatialIndex {
20857
20844
  }
20858
20845
  }
20859
20846
  sendManyToBack(items) {
20860
- const newItems = [...items];
20861
- this.itemsArray.forEach((item) => {
20862
- if (!items.includes(item)) {
20863
- newItems.push(item);
20847
+ const groups = this.splitItemsToGroups(items);
20848
+ Object.entries(groups).forEach(([key, value]) => {
20849
+ if (key !== "Board") {
20850
+ this.getById(key)?.index?.sendManyToBack(value);
20864
20851
  }
20865
20852
  });
20866
- this.itemsArray = newItems;
20867
- this.itemsArray.forEach(this.change.bind(this));
20853
+ if (groups["Board"]) {
20854
+ const newItems = [...groups["Board"]];
20855
+ this.itemsArray.forEach((item) => {
20856
+ if (!groups["Board"].includes(item)) {
20857
+ newItems.push(item);
20858
+ }
20859
+ });
20860
+ this.itemsArray = newItems;
20861
+ this.itemsArray.forEach(this.change.bind(this));
20862
+ }
20868
20863
  }
20869
20864
  bringToFront(item, shouldPublish = true) {
20865
+ if (item.parent !== "Board") {
20866
+ this.getById(item.parent)?.index?.bringToFront(item);
20867
+ if (shouldPublish) {
20868
+ this.subject.publish(this.items);
20869
+ }
20870
+ return;
20871
+ }
20870
20872
  const index2 = this.itemsArray.indexOf(item);
20871
20873
  this.itemsArray.splice(index2, 1);
20872
20874
  this.itemsArray.push(item);
@@ -20876,17 +20878,41 @@ class SpatialIndex {
20876
20878
  }
20877
20879
  }
20878
20880
  bringManyToFront(items) {
20879
- const newItems = [];
20880
- this.itemsArray.forEach((item) => {
20881
- if (!items.includes(item)) {
20882
- newItems.push(item);
20881
+ const groups = this.splitItemsToGroups(items);
20882
+ Object.entries(groups).forEach(([key, value]) => {
20883
+ if (key !== "Board") {
20884
+ this.getById(key)?.index?.bringManyToFront(value);
20883
20885
  }
20884
20886
  });
20885
- newItems.push(...items);
20886
- this.itemsArray = newItems;
20887
- this.itemsArray.forEach(this.change.bind(this));
20887
+ if (groups["Board"]) {
20888
+ const newItems = [];
20889
+ this.itemsArray.forEach((item) => {
20890
+ if (!groups["Board"].includes(item)) {
20891
+ newItems.push(item);
20892
+ }
20893
+ });
20894
+ newItems.push(...groups["Board"]);
20895
+ this.itemsArray = newItems;
20896
+ this.itemsArray.forEach(this.change.bind(this));
20897
+ }
20898
+ }
20899
+ splitItemsToGroups(items) {
20900
+ const groups = {};
20901
+ for (const item of items) {
20902
+ if (!groups[item.parent]) {
20903
+ groups[item.parent] = [item];
20904
+ } else {
20905
+ groups[item.parent].push(item);
20906
+ }
20907
+ }
20908
+ return groups;
20888
20909
  }
20889
20910
  moveSecondAfterFirst(first, second) {
20911
+ if (first.parent !== "Board" && second.parent === first.parent) {
20912
+ this.getById(first.parent)?.index?.moveSecondAfterFirst(first, second);
20913
+ this.subject.publish(this.items);
20914
+ return;
20915
+ }
20890
20916
  const secondIndex = this.itemsArray.indexOf(second);
20891
20917
  this.itemsArray.splice(secondIndex, 1);
20892
20918
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20896,6 +20922,11 @@ class SpatialIndex {
20896
20922
  this.subject.publish(this.items);
20897
20923
  }
20898
20924
  moveSecondBeforeFirst(first, second) {
20925
+ if (first.parent !== "Board" && second.parent === first.parent) {
20926
+ this.getById(first.parent)?.index?.moveSecondBeforeFirst(first, second);
20927
+ this.subject.publish(this.items);
20928
+ return;
20929
+ }
20899
20930
  const secondIndex = this.itemsArray.indexOf(second);
20900
20931
  this.itemsArray.splice(secondIndex, 1);
20901
20932
  const firstIndex = this.itemsArray.indexOf(first);
package/dist/cjs/index.js CHANGED
@@ -18822,35 +18822,10 @@ class FrameCommand {
18822
18822
  };
18823
18823
  });
18824
18824
  case "addChildren":
18825
- return mapItemsByOperation(frame, (item) => {
18826
- return {
18827
- ...this.operation,
18828
- newData: { childIds: item.getChildrenIds() }
18829
- };
18830
- });
18831
18825
  case "removeChildren":
18832
18826
  return mapItemsByOperation(frame, (item) => {
18833
18827
  return {
18834
- ...this.operation,
18835
- newData: { childIds: item.getChildrenIds() }
18836
- };
18837
- });
18838
- default:
18839
- return mapItemsByOperation(frame, (item) => {
18840
- const op = this.operation;
18841
- let newData = {};
18842
- if (op.prevData) {
18843
- newData = { ...op.prevData };
18844
- } else {
18845
- Object.keys(op.newData).forEach((key) => {
18846
- if (item[key]) {
18847
- newData[key] = item[key];
18848
- }
18849
- });
18850
- }
18851
- return {
18852
- ...op,
18853
- newData
18828
+ ...this.operation
18854
18829
  };
18855
18830
  });
18856
18831
  }
@@ -20832,6 +20807,11 @@ class SpatialIndex {
20832
20807
  return this.getById(item.parent);
20833
20808
  }
20834
20809
  moveToZIndex(item, zIndex) {
20810
+ if (item.parent !== "Board") {
20811
+ this.getById(item.parent)?.index?.moveToZIndex(item, zIndex);
20812
+ this.subject.publish(this.items);
20813
+ return;
20814
+ }
20835
20815
  const index2 = this.itemsArray.indexOf(item);
20836
20816
  this.itemsArray.splice(index2, 1);
20837
20817
  this.itemsArray.splice(zIndex, 0, item);
@@ -20848,6 +20828,13 @@ class SpatialIndex {
20848
20828
  this.itemsArray.forEach(this.change.bind(this));
20849
20829
  }
20850
20830
  sendToBack(item, shouldPublish = true) {
20831
+ if (item.parent !== "Board") {
20832
+ this.getById(item.parent)?.index?.sendToBack(item);
20833
+ if (shouldPublish) {
20834
+ this.subject.publish(this.items);
20835
+ }
20836
+ return;
20837
+ }
20851
20838
  const index2 = this.itemsArray.indexOf(item);
20852
20839
  this.itemsArray.splice(index2, 1);
20853
20840
  this.itemsArray.unshift(item);
@@ -20857,16 +20844,31 @@ class SpatialIndex {
20857
20844
  }
20858
20845
  }
20859
20846
  sendManyToBack(items) {
20860
- const newItems = [...items];
20861
- this.itemsArray.forEach((item) => {
20862
- if (!items.includes(item)) {
20863
- newItems.push(item);
20847
+ const groups = this.splitItemsToGroups(items);
20848
+ Object.entries(groups).forEach(([key, value]) => {
20849
+ if (key !== "Board") {
20850
+ this.getById(key)?.index?.sendManyToBack(value);
20864
20851
  }
20865
20852
  });
20866
- this.itemsArray = newItems;
20867
- this.itemsArray.forEach(this.change.bind(this));
20853
+ if (groups["Board"]) {
20854
+ const newItems = [...groups["Board"]];
20855
+ this.itemsArray.forEach((item) => {
20856
+ if (!groups["Board"].includes(item)) {
20857
+ newItems.push(item);
20858
+ }
20859
+ });
20860
+ this.itemsArray = newItems;
20861
+ this.itemsArray.forEach(this.change.bind(this));
20862
+ }
20868
20863
  }
20869
20864
  bringToFront(item, shouldPublish = true) {
20865
+ if (item.parent !== "Board") {
20866
+ this.getById(item.parent)?.index?.bringToFront(item);
20867
+ if (shouldPublish) {
20868
+ this.subject.publish(this.items);
20869
+ }
20870
+ return;
20871
+ }
20870
20872
  const index2 = this.itemsArray.indexOf(item);
20871
20873
  this.itemsArray.splice(index2, 1);
20872
20874
  this.itemsArray.push(item);
@@ -20876,17 +20878,41 @@ class SpatialIndex {
20876
20878
  }
20877
20879
  }
20878
20880
  bringManyToFront(items) {
20879
- const newItems = [];
20880
- this.itemsArray.forEach((item) => {
20881
- if (!items.includes(item)) {
20882
- newItems.push(item);
20881
+ const groups = this.splitItemsToGroups(items);
20882
+ Object.entries(groups).forEach(([key, value]) => {
20883
+ if (key !== "Board") {
20884
+ this.getById(key)?.index?.bringManyToFront(value);
20883
20885
  }
20884
20886
  });
20885
- newItems.push(...items);
20886
- this.itemsArray = newItems;
20887
- this.itemsArray.forEach(this.change.bind(this));
20887
+ if (groups["Board"]) {
20888
+ const newItems = [];
20889
+ this.itemsArray.forEach((item) => {
20890
+ if (!groups["Board"].includes(item)) {
20891
+ newItems.push(item);
20892
+ }
20893
+ });
20894
+ newItems.push(...groups["Board"]);
20895
+ this.itemsArray = newItems;
20896
+ this.itemsArray.forEach(this.change.bind(this));
20897
+ }
20898
+ }
20899
+ splitItemsToGroups(items) {
20900
+ const groups = {};
20901
+ for (const item of items) {
20902
+ if (!groups[item.parent]) {
20903
+ groups[item.parent] = [item];
20904
+ } else {
20905
+ groups[item.parent].push(item);
20906
+ }
20907
+ }
20908
+ return groups;
20888
20909
  }
20889
20910
  moveSecondAfterFirst(first, second) {
20911
+ if (first.parent !== "Board" && second.parent === first.parent) {
20912
+ this.getById(first.parent)?.index?.moveSecondAfterFirst(first, second);
20913
+ this.subject.publish(this.items);
20914
+ return;
20915
+ }
20890
20916
  const secondIndex = this.itemsArray.indexOf(second);
20891
20917
  this.itemsArray.splice(secondIndex, 1);
20892
20918
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20896,6 +20922,11 @@ class SpatialIndex {
20896
20922
  this.subject.publish(this.items);
20897
20923
  }
20898
20924
  moveSecondBeforeFirst(first, second) {
20925
+ if (first.parent !== "Board" && second.parent === first.parent) {
20926
+ this.getById(first.parent)?.index?.moveSecondBeforeFirst(first, second);
20927
+ this.subject.publish(this.items);
20928
+ return;
20929
+ }
20899
20930
  const secondIndex = this.itemsArray.indexOf(second);
20900
20931
  this.itemsArray.splice(secondIndex, 1);
20901
20932
  const firstIndex = this.itemsArray.indexOf(first);
package/dist/cjs/node.js CHANGED
@@ -21362,35 +21362,10 @@ class FrameCommand {
21362
21362
  };
21363
21363
  });
21364
21364
  case "addChildren":
21365
- return mapItemsByOperation(frame, (item) => {
21366
- return {
21367
- ...this.operation,
21368
- newData: { childIds: item.getChildrenIds() }
21369
- };
21370
- });
21371
21365
  case "removeChildren":
21372
21366
  return mapItemsByOperation(frame, (item) => {
21373
21367
  return {
21374
- ...this.operation,
21375
- newData: { childIds: item.getChildrenIds() }
21376
- };
21377
- });
21378
- default:
21379
- return mapItemsByOperation(frame, (item) => {
21380
- const op = this.operation;
21381
- let newData = {};
21382
- if (op.prevData) {
21383
- newData = { ...op.prevData };
21384
- } else {
21385
- Object.keys(op.newData).forEach((key) => {
21386
- if (item[key]) {
21387
- newData[key] = item[key];
21388
- }
21389
- });
21390
- }
21391
- return {
21392
- ...op,
21393
- newData
21368
+ ...this.operation
21394
21369
  };
21395
21370
  });
21396
21371
  }
@@ -23304,6 +23279,11 @@ class SpatialIndex {
23304
23279
  return this.getById(item.parent);
23305
23280
  }
23306
23281
  moveToZIndex(item, zIndex) {
23282
+ if (item.parent !== "Board") {
23283
+ this.getById(item.parent)?.index?.moveToZIndex(item, zIndex);
23284
+ this.subject.publish(this.items);
23285
+ return;
23286
+ }
23307
23287
  const index2 = this.itemsArray.indexOf(item);
23308
23288
  this.itemsArray.splice(index2, 1);
23309
23289
  this.itemsArray.splice(zIndex, 0, item);
@@ -23320,6 +23300,13 @@ class SpatialIndex {
23320
23300
  this.itemsArray.forEach(this.change.bind(this));
23321
23301
  }
23322
23302
  sendToBack(item, shouldPublish = true) {
23303
+ if (item.parent !== "Board") {
23304
+ this.getById(item.parent)?.index?.sendToBack(item);
23305
+ if (shouldPublish) {
23306
+ this.subject.publish(this.items);
23307
+ }
23308
+ return;
23309
+ }
23323
23310
  const index2 = this.itemsArray.indexOf(item);
23324
23311
  this.itemsArray.splice(index2, 1);
23325
23312
  this.itemsArray.unshift(item);
@@ -23329,16 +23316,31 @@ class SpatialIndex {
23329
23316
  }
23330
23317
  }
23331
23318
  sendManyToBack(items) {
23332
- const newItems = [...items];
23333
- this.itemsArray.forEach((item) => {
23334
- if (!items.includes(item)) {
23335
- newItems.push(item);
23319
+ const groups = this.splitItemsToGroups(items);
23320
+ Object.entries(groups).forEach(([key, value]) => {
23321
+ if (key !== "Board") {
23322
+ this.getById(key)?.index?.sendManyToBack(value);
23336
23323
  }
23337
23324
  });
23338
- this.itemsArray = newItems;
23339
- this.itemsArray.forEach(this.change.bind(this));
23325
+ if (groups["Board"]) {
23326
+ const newItems = [...groups["Board"]];
23327
+ this.itemsArray.forEach((item) => {
23328
+ if (!groups["Board"].includes(item)) {
23329
+ newItems.push(item);
23330
+ }
23331
+ });
23332
+ this.itemsArray = newItems;
23333
+ this.itemsArray.forEach(this.change.bind(this));
23334
+ }
23340
23335
  }
23341
23336
  bringToFront(item, shouldPublish = true) {
23337
+ if (item.parent !== "Board") {
23338
+ this.getById(item.parent)?.index?.bringToFront(item);
23339
+ if (shouldPublish) {
23340
+ this.subject.publish(this.items);
23341
+ }
23342
+ return;
23343
+ }
23342
23344
  const index2 = this.itemsArray.indexOf(item);
23343
23345
  this.itemsArray.splice(index2, 1);
23344
23346
  this.itemsArray.push(item);
@@ -23348,17 +23350,41 @@ class SpatialIndex {
23348
23350
  }
23349
23351
  }
23350
23352
  bringManyToFront(items) {
23351
- const newItems = [];
23352
- this.itemsArray.forEach((item) => {
23353
- if (!items.includes(item)) {
23354
- newItems.push(item);
23353
+ const groups = this.splitItemsToGroups(items);
23354
+ Object.entries(groups).forEach(([key, value]) => {
23355
+ if (key !== "Board") {
23356
+ this.getById(key)?.index?.bringManyToFront(value);
23355
23357
  }
23356
23358
  });
23357
- newItems.push(...items);
23358
- this.itemsArray = newItems;
23359
- this.itemsArray.forEach(this.change.bind(this));
23359
+ if (groups["Board"]) {
23360
+ const newItems = [];
23361
+ this.itemsArray.forEach((item) => {
23362
+ if (!groups["Board"].includes(item)) {
23363
+ newItems.push(item);
23364
+ }
23365
+ });
23366
+ newItems.push(...groups["Board"]);
23367
+ this.itemsArray = newItems;
23368
+ this.itemsArray.forEach(this.change.bind(this));
23369
+ }
23370
+ }
23371
+ splitItemsToGroups(items) {
23372
+ const groups = {};
23373
+ for (const item of items) {
23374
+ if (!groups[item.parent]) {
23375
+ groups[item.parent] = [item];
23376
+ } else {
23377
+ groups[item.parent].push(item);
23378
+ }
23379
+ }
23380
+ return groups;
23360
23381
  }
23361
23382
  moveSecondAfterFirst(first, second) {
23383
+ if (first.parent !== "Board" && second.parent === first.parent) {
23384
+ this.getById(first.parent)?.index?.moveSecondAfterFirst(first, second);
23385
+ this.subject.publish(this.items);
23386
+ return;
23387
+ }
23362
23388
  const secondIndex = this.itemsArray.indexOf(second);
23363
23389
  this.itemsArray.splice(secondIndex, 1);
23364
23390
  const firstIndex = this.itemsArray.indexOf(first);
@@ -23368,6 +23394,11 @@ class SpatialIndex {
23368
23394
  this.subject.publish(this.items);
23369
23395
  }
23370
23396
  moveSecondBeforeFirst(first, second) {
23397
+ if (first.parent !== "Board" && second.parent === first.parent) {
23398
+ this.getById(first.parent)?.index?.moveSecondBeforeFirst(first, second);
23399
+ this.subject.publish(this.items);
23400
+ return;
23401
+ }
23371
23402
  const secondIndex = this.itemsArray.indexOf(second);
23372
23403
  this.itemsArray.splice(secondIndex, 1);
23373
23404
  const firstIndex = this.itemsArray.indexOf(first);
@@ -18672,35 +18672,10 @@ class FrameCommand {
18672
18672
  };
18673
18673
  });
18674
18674
  case "addChildren":
18675
- return mapItemsByOperation(frame, (item) => {
18676
- return {
18677
- ...this.operation,
18678
- newData: { childIds: item.getChildrenIds() }
18679
- };
18680
- });
18681
18675
  case "removeChildren":
18682
18676
  return mapItemsByOperation(frame, (item) => {
18683
18677
  return {
18684
- ...this.operation,
18685
- newData: { childIds: item.getChildrenIds() }
18686
- };
18687
- });
18688
- default:
18689
- return mapItemsByOperation(frame, (item) => {
18690
- const op = this.operation;
18691
- let newData = {};
18692
- if (op.prevData) {
18693
- newData = { ...op.prevData };
18694
- } else {
18695
- Object.keys(op.newData).forEach((key) => {
18696
- if (item[key]) {
18697
- newData[key] = item[key];
18698
- }
18699
- });
18700
- }
18701
- return {
18702
- ...op,
18703
- newData
18678
+ ...this.operation
18704
18679
  };
18705
18680
  });
18706
18681
  }
@@ -20682,6 +20657,11 @@ class SpatialIndex {
20682
20657
  return this.getById(item.parent);
20683
20658
  }
20684
20659
  moveToZIndex(item, zIndex) {
20660
+ if (item.parent !== "Board") {
20661
+ this.getById(item.parent)?.index?.moveToZIndex(item, zIndex);
20662
+ this.subject.publish(this.items);
20663
+ return;
20664
+ }
20685
20665
  const index2 = this.itemsArray.indexOf(item);
20686
20666
  this.itemsArray.splice(index2, 1);
20687
20667
  this.itemsArray.splice(zIndex, 0, item);
@@ -20698,6 +20678,13 @@ class SpatialIndex {
20698
20678
  this.itemsArray.forEach(this.change.bind(this));
20699
20679
  }
20700
20680
  sendToBack(item, shouldPublish = true) {
20681
+ if (item.parent !== "Board") {
20682
+ this.getById(item.parent)?.index?.sendToBack(item);
20683
+ if (shouldPublish) {
20684
+ this.subject.publish(this.items);
20685
+ }
20686
+ return;
20687
+ }
20701
20688
  const index2 = this.itemsArray.indexOf(item);
20702
20689
  this.itemsArray.splice(index2, 1);
20703
20690
  this.itemsArray.unshift(item);
@@ -20707,16 +20694,31 @@ class SpatialIndex {
20707
20694
  }
20708
20695
  }
20709
20696
  sendManyToBack(items) {
20710
- const newItems = [...items];
20711
- this.itemsArray.forEach((item) => {
20712
- if (!items.includes(item)) {
20713
- newItems.push(item);
20697
+ const groups = this.splitItemsToGroups(items);
20698
+ Object.entries(groups).forEach(([key, value]) => {
20699
+ if (key !== "Board") {
20700
+ this.getById(key)?.index?.sendManyToBack(value);
20714
20701
  }
20715
20702
  });
20716
- this.itemsArray = newItems;
20717
- this.itemsArray.forEach(this.change.bind(this));
20703
+ if (groups["Board"]) {
20704
+ const newItems = [...groups["Board"]];
20705
+ this.itemsArray.forEach((item) => {
20706
+ if (!groups["Board"].includes(item)) {
20707
+ newItems.push(item);
20708
+ }
20709
+ });
20710
+ this.itemsArray = newItems;
20711
+ this.itemsArray.forEach(this.change.bind(this));
20712
+ }
20718
20713
  }
20719
20714
  bringToFront(item, shouldPublish = true) {
20715
+ if (item.parent !== "Board") {
20716
+ this.getById(item.parent)?.index?.bringToFront(item);
20717
+ if (shouldPublish) {
20718
+ this.subject.publish(this.items);
20719
+ }
20720
+ return;
20721
+ }
20720
20722
  const index2 = this.itemsArray.indexOf(item);
20721
20723
  this.itemsArray.splice(index2, 1);
20722
20724
  this.itemsArray.push(item);
@@ -20726,17 +20728,41 @@ class SpatialIndex {
20726
20728
  }
20727
20729
  }
20728
20730
  bringManyToFront(items) {
20729
- const newItems = [];
20730
- this.itemsArray.forEach((item) => {
20731
- if (!items.includes(item)) {
20732
- newItems.push(item);
20731
+ const groups = this.splitItemsToGroups(items);
20732
+ Object.entries(groups).forEach(([key, value]) => {
20733
+ if (key !== "Board") {
20734
+ this.getById(key)?.index?.bringManyToFront(value);
20733
20735
  }
20734
20736
  });
20735
- newItems.push(...items);
20736
- this.itemsArray = newItems;
20737
- this.itemsArray.forEach(this.change.bind(this));
20737
+ if (groups["Board"]) {
20738
+ const newItems = [];
20739
+ this.itemsArray.forEach((item) => {
20740
+ if (!groups["Board"].includes(item)) {
20741
+ newItems.push(item);
20742
+ }
20743
+ });
20744
+ newItems.push(...groups["Board"]);
20745
+ this.itemsArray = newItems;
20746
+ this.itemsArray.forEach(this.change.bind(this));
20747
+ }
20748
+ }
20749
+ splitItemsToGroups(items) {
20750
+ const groups = {};
20751
+ for (const item of items) {
20752
+ if (!groups[item.parent]) {
20753
+ groups[item.parent] = [item];
20754
+ } else {
20755
+ groups[item.parent].push(item);
20756
+ }
20757
+ }
20758
+ return groups;
20738
20759
  }
20739
20760
  moveSecondAfterFirst(first, second) {
20761
+ if (first.parent !== "Board" && second.parent === first.parent) {
20762
+ this.getById(first.parent)?.index?.moveSecondAfterFirst(first, second);
20763
+ this.subject.publish(this.items);
20764
+ return;
20765
+ }
20740
20766
  const secondIndex = this.itemsArray.indexOf(second);
20741
20767
  this.itemsArray.splice(secondIndex, 1);
20742
20768
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20746,6 +20772,11 @@ class SpatialIndex {
20746
20772
  this.subject.publish(this.items);
20747
20773
  }
20748
20774
  moveSecondBeforeFirst(first, second) {
20775
+ if (first.parent !== "Board" && second.parent === first.parent) {
20776
+ this.getById(first.parent)?.index?.moveSecondBeforeFirst(first, second);
20777
+ this.subject.publish(this.items);
20778
+ return;
20779
+ }
20749
20780
  const secondIndex = this.itemsArray.indexOf(second);
20750
20781
  this.itemsArray.splice(secondIndex, 1);
20751
20782
  const firstIndex = this.itemsArray.indexOf(first);
package/dist/esm/index.js CHANGED
@@ -18665,35 +18665,10 @@ class FrameCommand {
18665
18665
  };
18666
18666
  });
18667
18667
  case "addChildren":
18668
- return mapItemsByOperation(frame, (item) => {
18669
- return {
18670
- ...this.operation,
18671
- newData: { childIds: item.getChildrenIds() }
18672
- };
18673
- });
18674
18668
  case "removeChildren":
18675
18669
  return mapItemsByOperation(frame, (item) => {
18676
18670
  return {
18677
- ...this.operation,
18678
- newData: { childIds: item.getChildrenIds() }
18679
- };
18680
- });
18681
- default:
18682
- return mapItemsByOperation(frame, (item) => {
18683
- const op = this.operation;
18684
- let newData = {};
18685
- if (op.prevData) {
18686
- newData = { ...op.prevData };
18687
- } else {
18688
- Object.keys(op.newData).forEach((key) => {
18689
- if (item[key]) {
18690
- newData[key] = item[key];
18691
- }
18692
- });
18693
- }
18694
- return {
18695
- ...op,
18696
- newData
18671
+ ...this.operation
18697
18672
  };
18698
18673
  });
18699
18674
  }
@@ -20675,6 +20650,11 @@ class SpatialIndex {
20675
20650
  return this.getById(item.parent);
20676
20651
  }
20677
20652
  moveToZIndex(item, zIndex) {
20653
+ if (item.parent !== "Board") {
20654
+ this.getById(item.parent)?.index?.moveToZIndex(item, zIndex);
20655
+ this.subject.publish(this.items);
20656
+ return;
20657
+ }
20678
20658
  const index2 = this.itemsArray.indexOf(item);
20679
20659
  this.itemsArray.splice(index2, 1);
20680
20660
  this.itemsArray.splice(zIndex, 0, item);
@@ -20691,6 +20671,13 @@ class SpatialIndex {
20691
20671
  this.itemsArray.forEach(this.change.bind(this));
20692
20672
  }
20693
20673
  sendToBack(item, shouldPublish = true) {
20674
+ if (item.parent !== "Board") {
20675
+ this.getById(item.parent)?.index?.sendToBack(item);
20676
+ if (shouldPublish) {
20677
+ this.subject.publish(this.items);
20678
+ }
20679
+ return;
20680
+ }
20694
20681
  const index2 = this.itemsArray.indexOf(item);
20695
20682
  this.itemsArray.splice(index2, 1);
20696
20683
  this.itemsArray.unshift(item);
@@ -20700,16 +20687,31 @@ class SpatialIndex {
20700
20687
  }
20701
20688
  }
20702
20689
  sendManyToBack(items) {
20703
- const newItems = [...items];
20704
- this.itemsArray.forEach((item) => {
20705
- if (!items.includes(item)) {
20706
- newItems.push(item);
20690
+ const groups = this.splitItemsToGroups(items);
20691
+ Object.entries(groups).forEach(([key, value]) => {
20692
+ if (key !== "Board") {
20693
+ this.getById(key)?.index?.sendManyToBack(value);
20707
20694
  }
20708
20695
  });
20709
- this.itemsArray = newItems;
20710
- this.itemsArray.forEach(this.change.bind(this));
20696
+ if (groups["Board"]) {
20697
+ const newItems = [...groups["Board"]];
20698
+ this.itemsArray.forEach((item) => {
20699
+ if (!groups["Board"].includes(item)) {
20700
+ newItems.push(item);
20701
+ }
20702
+ });
20703
+ this.itemsArray = newItems;
20704
+ this.itemsArray.forEach(this.change.bind(this));
20705
+ }
20711
20706
  }
20712
20707
  bringToFront(item, shouldPublish = true) {
20708
+ if (item.parent !== "Board") {
20709
+ this.getById(item.parent)?.index?.bringToFront(item);
20710
+ if (shouldPublish) {
20711
+ this.subject.publish(this.items);
20712
+ }
20713
+ return;
20714
+ }
20713
20715
  const index2 = this.itemsArray.indexOf(item);
20714
20716
  this.itemsArray.splice(index2, 1);
20715
20717
  this.itemsArray.push(item);
@@ -20719,17 +20721,41 @@ class SpatialIndex {
20719
20721
  }
20720
20722
  }
20721
20723
  bringManyToFront(items) {
20722
- const newItems = [];
20723
- this.itemsArray.forEach((item) => {
20724
- if (!items.includes(item)) {
20725
- newItems.push(item);
20724
+ const groups = this.splitItemsToGroups(items);
20725
+ Object.entries(groups).forEach(([key, value]) => {
20726
+ if (key !== "Board") {
20727
+ this.getById(key)?.index?.bringManyToFront(value);
20726
20728
  }
20727
20729
  });
20728
- newItems.push(...items);
20729
- this.itemsArray = newItems;
20730
- this.itemsArray.forEach(this.change.bind(this));
20730
+ if (groups["Board"]) {
20731
+ const newItems = [];
20732
+ this.itemsArray.forEach((item) => {
20733
+ if (!groups["Board"].includes(item)) {
20734
+ newItems.push(item);
20735
+ }
20736
+ });
20737
+ newItems.push(...groups["Board"]);
20738
+ this.itemsArray = newItems;
20739
+ this.itemsArray.forEach(this.change.bind(this));
20740
+ }
20741
+ }
20742
+ splitItemsToGroups(items) {
20743
+ const groups = {};
20744
+ for (const item of items) {
20745
+ if (!groups[item.parent]) {
20746
+ groups[item.parent] = [item];
20747
+ } else {
20748
+ groups[item.parent].push(item);
20749
+ }
20750
+ }
20751
+ return groups;
20731
20752
  }
20732
20753
  moveSecondAfterFirst(first, second) {
20754
+ if (first.parent !== "Board" && second.parent === first.parent) {
20755
+ this.getById(first.parent)?.index?.moveSecondAfterFirst(first, second);
20756
+ this.subject.publish(this.items);
20757
+ return;
20758
+ }
20733
20759
  const secondIndex = this.itemsArray.indexOf(second);
20734
20760
  this.itemsArray.splice(secondIndex, 1);
20735
20761
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20739,6 +20765,11 @@ class SpatialIndex {
20739
20765
  this.subject.publish(this.items);
20740
20766
  }
20741
20767
  moveSecondBeforeFirst(first, second) {
20768
+ if (first.parent !== "Board" && second.parent === first.parent) {
20769
+ this.getById(first.parent)?.index?.moveSecondBeforeFirst(first, second);
20770
+ this.subject.publish(this.items);
20771
+ return;
20772
+ }
20742
20773
  const secondIndex = this.itemsArray.indexOf(second);
20743
20774
  this.itemsArray.splice(secondIndex, 1);
20744
20775
  const firstIndex = this.itemsArray.indexOf(first);
package/dist/esm/node.js CHANGED
@@ -21200,35 +21200,10 @@ class FrameCommand {
21200
21200
  };
21201
21201
  });
21202
21202
  case "addChildren":
21203
- return mapItemsByOperation(frame, (item) => {
21204
- return {
21205
- ...this.operation,
21206
- newData: { childIds: item.getChildrenIds() }
21207
- };
21208
- });
21209
21203
  case "removeChildren":
21210
21204
  return mapItemsByOperation(frame, (item) => {
21211
21205
  return {
21212
- ...this.operation,
21213
- newData: { childIds: item.getChildrenIds() }
21214
- };
21215
- });
21216
- default:
21217
- return mapItemsByOperation(frame, (item) => {
21218
- const op = this.operation;
21219
- let newData = {};
21220
- if (op.prevData) {
21221
- newData = { ...op.prevData };
21222
- } else {
21223
- Object.keys(op.newData).forEach((key) => {
21224
- if (item[key]) {
21225
- newData[key] = item[key];
21226
- }
21227
- });
21228
- }
21229
- return {
21230
- ...op,
21231
- newData
21206
+ ...this.operation
21232
21207
  };
21233
21208
  });
21234
21209
  }
@@ -23142,6 +23117,11 @@ class SpatialIndex {
23142
23117
  return this.getById(item.parent);
23143
23118
  }
23144
23119
  moveToZIndex(item, zIndex) {
23120
+ if (item.parent !== "Board") {
23121
+ this.getById(item.parent)?.index?.moveToZIndex(item, zIndex);
23122
+ this.subject.publish(this.items);
23123
+ return;
23124
+ }
23145
23125
  const index2 = this.itemsArray.indexOf(item);
23146
23126
  this.itemsArray.splice(index2, 1);
23147
23127
  this.itemsArray.splice(zIndex, 0, item);
@@ -23158,6 +23138,13 @@ class SpatialIndex {
23158
23138
  this.itemsArray.forEach(this.change.bind(this));
23159
23139
  }
23160
23140
  sendToBack(item, shouldPublish = true) {
23141
+ if (item.parent !== "Board") {
23142
+ this.getById(item.parent)?.index?.sendToBack(item);
23143
+ if (shouldPublish) {
23144
+ this.subject.publish(this.items);
23145
+ }
23146
+ return;
23147
+ }
23161
23148
  const index2 = this.itemsArray.indexOf(item);
23162
23149
  this.itemsArray.splice(index2, 1);
23163
23150
  this.itemsArray.unshift(item);
@@ -23167,16 +23154,31 @@ class SpatialIndex {
23167
23154
  }
23168
23155
  }
23169
23156
  sendManyToBack(items) {
23170
- const newItems = [...items];
23171
- this.itemsArray.forEach((item) => {
23172
- if (!items.includes(item)) {
23173
- newItems.push(item);
23157
+ const groups = this.splitItemsToGroups(items);
23158
+ Object.entries(groups).forEach(([key, value]) => {
23159
+ if (key !== "Board") {
23160
+ this.getById(key)?.index?.sendManyToBack(value);
23174
23161
  }
23175
23162
  });
23176
- this.itemsArray = newItems;
23177
- this.itemsArray.forEach(this.change.bind(this));
23163
+ if (groups["Board"]) {
23164
+ const newItems = [...groups["Board"]];
23165
+ this.itemsArray.forEach((item) => {
23166
+ if (!groups["Board"].includes(item)) {
23167
+ newItems.push(item);
23168
+ }
23169
+ });
23170
+ this.itemsArray = newItems;
23171
+ this.itemsArray.forEach(this.change.bind(this));
23172
+ }
23178
23173
  }
23179
23174
  bringToFront(item, shouldPublish = true) {
23175
+ if (item.parent !== "Board") {
23176
+ this.getById(item.parent)?.index?.bringToFront(item);
23177
+ if (shouldPublish) {
23178
+ this.subject.publish(this.items);
23179
+ }
23180
+ return;
23181
+ }
23180
23182
  const index2 = this.itemsArray.indexOf(item);
23181
23183
  this.itemsArray.splice(index2, 1);
23182
23184
  this.itemsArray.push(item);
@@ -23186,17 +23188,41 @@ class SpatialIndex {
23186
23188
  }
23187
23189
  }
23188
23190
  bringManyToFront(items) {
23189
- const newItems = [];
23190
- this.itemsArray.forEach((item) => {
23191
- if (!items.includes(item)) {
23192
- newItems.push(item);
23191
+ const groups = this.splitItemsToGroups(items);
23192
+ Object.entries(groups).forEach(([key, value]) => {
23193
+ if (key !== "Board") {
23194
+ this.getById(key)?.index?.bringManyToFront(value);
23193
23195
  }
23194
23196
  });
23195
- newItems.push(...items);
23196
- this.itemsArray = newItems;
23197
- this.itemsArray.forEach(this.change.bind(this));
23197
+ if (groups["Board"]) {
23198
+ const newItems = [];
23199
+ this.itemsArray.forEach((item) => {
23200
+ if (!groups["Board"].includes(item)) {
23201
+ newItems.push(item);
23202
+ }
23203
+ });
23204
+ newItems.push(...groups["Board"]);
23205
+ this.itemsArray = newItems;
23206
+ this.itemsArray.forEach(this.change.bind(this));
23207
+ }
23208
+ }
23209
+ splitItemsToGroups(items) {
23210
+ const groups = {};
23211
+ for (const item of items) {
23212
+ if (!groups[item.parent]) {
23213
+ groups[item.parent] = [item];
23214
+ } else {
23215
+ groups[item.parent].push(item);
23216
+ }
23217
+ }
23218
+ return groups;
23198
23219
  }
23199
23220
  moveSecondAfterFirst(first, second) {
23221
+ if (first.parent !== "Board" && second.parent === first.parent) {
23222
+ this.getById(first.parent)?.index?.moveSecondAfterFirst(first, second);
23223
+ this.subject.publish(this.items);
23224
+ return;
23225
+ }
23200
23226
  const secondIndex = this.itemsArray.indexOf(second);
23201
23227
  this.itemsArray.splice(secondIndex, 1);
23202
23228
  const firstIndex = this.itemsArray.indexOf(first);
@@ -23206,6 +23232,11 @@ class SpatialIndex {
23206
23232
  this.subject.publish(this.items);
23207
23233
  }
23208
23234
  moveSecondBeforeFirst(first, second) {
23235
+ if (first.parent !== "Board" && second.parent === first.parent) {
23236
+ this.getById(first.parent)?.index?.moveSecondBeforeFirst(first, second);
23237
+ this.subject.publish(this.items);
23238
+ return;
23239
+ }
23209
23240
  const secondIndex = this.itemsArray.indexOf(second);
23210
23241
  this.itemsArray.splice(secondIndex, 1);
23211
23242
  const firstIndex = this.itemsArray.indexOf(first);
@@ -28,6 +28,7 @@ export declare class SpatialIndex {
28
28
  sendManyToBack(items: Item[]): void;
29
29
  bringToFront(item: Item, shouldPublish?: boolean): void;
30
30
  bringManyToFront(items: Item[]): void;
31
+ private splitItemsToGroups;
31
32
  moveSecondAfterFirst(first: Item, second: Item): void;
32
33
  moveSecondBeforeFirst(first: Item, second: Item): void;
33
34
  getById(id: string): BaseItem | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.4.62",
3
+ "version": "0.4.64",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",