microboard-temp 0.4.63 → 0.4.65

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.
@@ -18828,24 +18828,6 @@ class FrameCommand {
18828
18828
  ...this.operation
18829
18829
  };
18830
18830
  });
18831
- default:
18832
- return mapItemsByOperation(frame, (item) => {
18833
- const op = this.operation;
18834
- let newData = {};
18835
- if (op.prevData) {
18836
- newData = { ...op.prevData };
18837
- } else {
18838
- Object.keys(op.newData).forEach((key) => {
18839
- if (item[key]) {
18840
- newData[key] = item[key];
18841
- }
18842
- });
18843
- }
18844
- return {
18845
- ...op,
18846
- newData
18847
- };
18848
- });
18849
18831
  }
18850
18832
  }
18851
18833
  }
@@ -20825,6 +20807,11 @@ class SpatialIndex {
20825
20807
  return this.getById(item.parent);
20826
20808
  }
20827
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
+ }
20828
20815
  const index2 = this.itemsArray.indexOf(item);
20829
20816
  this.itemsArray.splice(index2, 1);
20830
20817
  this.itemsArray.splice(zIndex, 0, item);
@@ -20841,6 +20828,13 @@ class SpatialIndex {
20841
20828
  this.itemsArray.forEach(this.change.bind(this));
20842
20829
  }
20843
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
+ }
20844
20838
  const index2 = this.itemsArray.indexOf(item);
20845
20839
  this.itemsArray.splice(index2, 1);
20846
20840
  this.itemsArray.unshift(item);
@@ -20850,16 +20844,31 @@ class SpatialIndex {
20850
20844
  }
20851
20845
  }
20852
20846
  sendManyToBack(items) {
20853
- const newItems = [...items];
20854
- this.itemsArray.forEach((item) => {
20855
- if (!items.includes(item)) {
20856
- 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);
20857
20851
  }
20858
20852
  });
20859
- this.itemsArray = newItems;
20860
- 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
+ }
20861
20863
  }
20862
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
+ }
20863
20872
  const index2 = this.itemsArray.indexOf(item);
20864
20873
  this.itemsArray.splice(index2, 1);
20865
20874
  this.itemsArray.push(item);
@@ -20869,17 +20878,41 @@ class SpatialIndex {
20869
20878
  }
20870
20879
  }
20871
20880
  bringManyToFront(items) {
20872
- const newItems = [];
20873
- this.itemsArray.forEach((item) => {
20874
- if (!items.includes(item)) {
20875
- 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);
20876
20885
  }
20877
20886
  });
20878
- newItems.push(...items);
20879
- this.itemsArray = newItems;
20880
- 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;
20881
20909
  }
20882
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
+ }
20883
20916
  const secondIndex = this.itemsArray.indexOf(second);
20884
20917
  this.itemsArray.splice(secondIndex, 1);
20885
20918
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20889,6 +20922,11 @@ class SpatialIndex {
20889
20922
  this.subject.publish(this.items);
20890
20923
  }
20891
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
+ }
20892
20930
  const secondIndex = this.itemsArray.indexOf(second);
20893
20931
  this.itemsArray.splice(secondIndex, 1);
20894
20932
  const firstIndex = this.itemsArray.indexOf(first);
@@ -53704,14 +53742,14 @@ class Board {
53704
53742
  const items = Array.from(itemsDiv.children).map((el) => this.parseHTML(el));
53705
53743
  this.index.clear();
53706
53744
  const createdConnectors = {};
53707
- const createdFrames = {};
53745
+ const createdGroups = {};
53708
53746
  const addItem = (itemData) => {
53709
53747
  const item = this.createItem(itemData.id, itemData);
53710
53748
  if (item instanceof Connector2) {
53711
53749
  createdConnectors[itemData.id] = { item, itemData };
53712
53750
  }
53713
- if (item instanceof Frame2) {
53714
- createdFrames[item.getId()] = { item, itemData };
53751
+ if ("index" in item && item.index) {
53752
+ createdGroups[item.getId()] = { item, itemData };
53715
53753
  }
53716
53754
  this.index.insert(item);
53717
53755
  return item;
@@ -53729,8 +53767,8 @@ class Board {
53729
53767
  item.applyStartPoint(itemData.startPoint);
53730
53768
  item.applyEndPoint(itemData.endPoint);
53731
53769
  }
53732
- for (const key in createdFrames) {
53733
- const { item, itemData } = createdFrames[key];
53770
+ for (const key in createdGroups) {
53771
+ const { item, itemData } = createdGroups[key];
53734
53772
  item.applyAddChildren(itemData.children);
53735
53773
  }
53736
53774
  }
package/dist/cjs/index.js CHANGED
@@ -18828,24 +18828,6 @@ class FrameCommand {
18828
18828
  ...this.operation
18829
18829
  };
18830
18830
  });
18831
- default:
18832
- return mapItemsByOperation(frame, (item) => {
18833
- const op = this.operation;
18834
- let newData = {};
18835
- if (op.prevData) {
18836
- newData = { ...op.prevData };
18837
- } else {
18838
- Object.keys(op.newData).forEach((key) => {
18839
- if (item[key]) {
18840
- newData[key] = item[key];
18841
- }
18842
- });
18843
- }
18844
- return {
18845
- ...op,
18846
- newData
18847
- };
18848
- });
18849
18831
  }
18850
18832
  }
18851
18833
  }
@@ -20825,6 +20807,11 @@ class SpatialIndex {
20825
20807
  return this.getById(item.parent);
20826
20808
  }
20827
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
+ }
20828
20815
  const index2 = this.itemsArray.indexOf(item);
20829
20816
  this.itemsArray.splice(index2, 1);
20830
20817
  this.itemsArray.splice(zIndex, 0, item);
@@ -20841,6 +20828,13 @@ class SpatialIndex {
20841
20828
  this.itemsArray.forEach(this.change.bind(this));
20842
20829
  }
20843
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
+ }
20844
20838
  const index2 = this.itemsArray.indexOf(item);
20845
20839
  this.itemsArray.splice(index2, 1);
20846
20840
  this.itemsArray.unshift(item);
@@ -20850,16 +20844,31 @@ class SpatialIndex {
20850
20844
  }
20851
20845
  }
20852
20846
  sendManyToBack(items) {
20853
- const newItems = [...items];
20854
- this.itemsArray.forEach((item) => {
20855
- if (!items.includes(item)) {
20856
- 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);
20857
20851
  }
20858
20852
  });
20859
- this.itemsArray = newItems;
20860
- 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
+ }
20861
20863
  }
20862
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
+ }
20863
20872
  const index2 = this.itemsArray.indexOf(item);
20864
20873
  this.itemsArray.splice(index2, 1);
20865
20874
  this.itemsArray.push(item);
@@ -20869,17 +20878,41 @@ class SpatialIndex {
20869
20878
  }
20870
20879
  }
20871
20880
  bringManyToFront(items) {
20872
- const newItems = [];
20873
- this.itemsArray.forEach((item) => {
20874
- if (!items.includes(item)) {
20875
- 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);
20876
20885
  }
20877
20886
  });
20878
- newItems.push(...items);
20879
- this.itemsArray = newItems;
20880
- 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;
20881
20909
  }
20882
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
+ }
20883
20916
  const secondIndex = this.itemsArray.indexOf(second);
20884
20917
  this.itemsArray.splice(secondIndex, 1);
20885
20918
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20889,6 +20922,11 @@ class SpatialIndex {
20889
20922
  this.subject.publish(this.items);
20890
20923
  }
20891
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
+ }
20892
20930
  const secondIndex = this.itemsArray.indexOf(second);
20893
20931
  this.itemsArray.splice(secondIndex, 1);
20894
20932
  const firstIndex = this.itemsArray.indexOf(first);
@@ -53704,14 +53742,14 @@ class Board {
53704
53742
  const items = Array.from(itemsDiv.children).map((el) => this.parseHTML(el));
53705
53743
  this.index.clear();
53706
53744
  const createdConnectors = {};
53707
- const createdFrames = {};
53745
+ const createdGroups = {};
53708
53746
  const addItem = (itemData) => {
53709
53747
  const item = this.createItem(itemData.id, itemData);
53710
53748
  if (item instanceof Connector2) {
53711
53749
  createdConnectors[itemData.id] = { item, itemData };
53712
53750
  }
53713
- if (item instanceof Frame2) {
53714
- createdFrames[item.getId()] = { item, itemData };
53751
+ if ("index" in item && item.index) {
53752
+ createdGroups[item.getId()] = { item, itemData };
53715
53753
  }
53716
53754
  this.index.insert(item);
53717
53755
  return item;
@@ -53729,8 +53767,8 @@ class Board {
53729
53767
  item.applyStartPoint(itemData.startPoint);
53730
53768
  item.applyEndPoint(itemData.endPoint);
53731
53769
  }
53732
- for (const key in createdFrames) {
53733
- const { item, itemData } = createdFrames[key];
53770
+ for (const key in createdGroups) {
53771
+ const { item, itemData } = createdGroups[key];
53734
53772
  item.applyAddChildren(itemData.children);
53735
53773
  }
53736
53774
  }
package/dist/cjs/node.js CHANGED
@@ -21368,24 +21368,6 @@ class FrameCommand {
21368
21368
  ...this.operation
21369
21369
  };
21370
21370
  });
21371
- default:
21372
- return mapItemsByOperation(frame, (item) => {
21373
- const op = this.operation;
21374
- let newData = {};
21375
- if (op.prevData) {
21376
- newData = { ...op.prevData };
21377
- } else {
21378
- Object.keys(op.newData).forEach((key) => {
21379
- if (item[key]) {
21380
- newData[key] = item[key];
21381
- }
21382
- });
21383
- }
21384
- return {
21385
- ...op,
21386
- newData
21387
- };
21388
- });
21389
21371
  }
21390
21372
  }
21391
21373
  }
@@ -23297,6 +23279,11 @@ class SpatialIndex {
23297
23279
  return this.getById(item.parent);
23298
23280
  }
23299
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
+ }
23300
23287
  const index2 = this.itemsArray.indexOf(item);
23301
23288
  this.itemsArray.splice(index2, 1);
23302
23289
  this.itemsArray.splice(zIndex, 0, item);
@@ -23313,6 +23300,13 @@ class SpatialIndex {
23313
23300
  this.itemsArray.forEach(this.change.bind(this));
23314
23301
  }
23315
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
+ }
23316
23310
  const index2 = this.itemsArray.indexOf(item);
23317
23311
  this.itemsArray.splice(index2, 1);
23318
23312
  this.itemsArray.unshift(item);
@@ -23322,16 +23316,31 @@ class SpatialIndex {
23322
23316
  }
23323
23317
  }
23324
23318
  sendManyToBack(items) {
23325
- const newItems = [...items];
23326
- this.itemsArray.forEach((item) => {
23327
- if (!items.includes(item)) {
23328
- 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);
23329
23323
  }
23330
23324
  });
23331
- this.itemsArray = newItems;
23332
- 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
+ }
23333
23335
  }
23334
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
+ }
23335
23344
  const index2 = this.itemsArray.indexOf(item);
23336
23345
  this.itemsArray.splice(index2, 1);
23337
23346
  this.itemsArray.push(item);
@@ -23341,17 +23350,41 @@ class SpatialIndex {
23341
23350
  }
23342
23351
  }
23343
23352
  bringManyToFront(items) {
23344
- const newItems = [];
23345
- this.itemsArray.forEach((item) => {
23346
- if (!items.includes(item)) {
23347
- 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);
23348
23357
  }
23349
23358
  });
23350
- newItems.push(...items);
23351
- this.itemsArray = newItems;
23352
- 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;
23353
23381
  }
23354
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
+ }
23355
23388
  const secondIndex = this.itemsArray.indexOf(second);
23356
23389
  this.itemsArray.splice(secondIndex, 1);
23357
23390
  const firstIndex = this.itemsArray.indexOf(first);
@@ -23361,6 +23394,11 @@ class SpatialIndex {
23361
23394
  this.subject.publish(this.items);
23362
23395
  }
23363
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
+ }
23364
23402
  const secondIndex = this.itemsArray.indexOf(second);
23365
23403
  this.itemsArray.splice(secondIndex, 1);
23366
23404
  const firstIndex = this.itemsArray.indexOf(first);
@@ -56177,14 +56215,14 @@ class Board {
56177
56215
  const items = Array.from(itemsDiv.children).map((el) => this.parseHTML(el));
56178
56216
  this.index.clear();
56179
56217
  const createdConnectors = {};
56180
- const createdFrames = {};
56218
+ const createdGroups = {};
56181
56219
  const addItem = (itemData) => {
56182
56220
  const item = this.createItem(itemData.id, itemData);
56183
56221
  if (item instanceof Connector2) {
56184
56222
  createdConnectors[itemData.id] = { item, itemData };
56185
56223
  }
56186
- if (item instanceof Frame2) {
56187
- createdFrames[item.getId()] = { item, itemData };
56224
+ if ("index" in item && item.index) {
56225
+ createdGroups[item.getId()] = { item, itemData };
56188
56226
  }
56189
56227
  this.index.insert(item);
56190
56228
  return item;
@@ -56202,8 +56240,8 @@ class Board {
56202
56240
  item.applyStartPoint(itemData.startPoint);
56203
56241
  item.applyEndPoint(itemData.endPoint);
56204
56242
  }
56205
- for (const key in createdFrames) {
56206
- const { item, itemData } = createdFrames[key];
56243
+ for (const key in createdGroups) {
56244
+ const { item, itemData } = createdGroups[key];
56207
56245
  item.applyAddChildren(itemData.children);
56208
56246
  }
56209
56247
  }
@@ -18678,24 +18678,6 @@ class FrameCommand {
18678
18678
  ...this.operation
18679
18679
  };
18680
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
18697
- };
18698
- });
18699
18681
  }
18700
18682
  }
18701
18683
  }
@@ -20675,6 +20657,11 @@ class SpatialIndex {
20675
20657
  return this.getById(item.parent);
20676
20658
  }
20677
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
+ }
20678
20665
  const index2 = this.itemsArray.indexOf(item);
20679
20666
  this.itemsArray.splice(index2, 1);
20680
20667
  this.itemsArray.splice(zIndex, 0, item);
@@ -20691,6 +20678,13 @@ class SpatialIndex {
20691
20678
  this.itemsArray.forEach(this.change.bind(this));
20692
20679
  }
20693
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
+ }
20694
20688
  const index2 = this.itemsArray.indexOf(item);
20695
20689
  this.itemsArray.splice(index2, 1);
20696
20690
  this.itemsArray.unshift(item);
@@ -20700,16 +20694,31 @@ class SpatialIndex {
20700
20694
  }
20701
20695
  }
20702
20696
  sendManyToBack(items) {
20703
- const newItems = [...items];
20704
- this.itemsArray.forEach((item) => {
20705
- if (!items.includes(item)) {
20706
- 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);
20707
20701
  }
20708
20702
  });
20709
- this.itemsArray = newItems;
20710
- 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
+ }
20711
20713
  }
20712
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
+ }
20713
20722
  const index2 = this.itemsArray.indexOf(item);
20714
20723
  this.itemsArray.splice(index2, 1);
20715
20724
  this.itemsArray.push(item);
@@ -20719,17 +20728,41 @@ class SpatialIndex {
20719
20728
  }
20720
20729
  }
20721
20730
  bringManyToFront(items) {
20722
- const newItems = [];
20723
- this.itemsArray.forEach((item) => {
20724
- if (!items.includes(item)) {
20725
- 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);
20726
20735
  }
20727
20736
  });
20728
- newItems.push(...items);
20729
- this.itemsArray = newItems;
20730
- 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;
20731
20759
  }
20732
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
+ }
20733
20766
  const secondIndex = this.itemsArray.indexOf(second);
20734
20767
  this.itemsArray.splice(secondIndex, 1);
20735
20768
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20739,6 +20772,11 @@ class SpatialIndex {
20739
20772
  this.subject.publish(this.items);
20740
20773
  }
20741
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
+ }
20742
20780
  const secondIndex = this.itemsArray.indexOf(second);
20743
20781
  this.itemsArray.splice(secondIndex, 1);
20744
20782
  const firstIndex = this.itemsArray.indexOf(first);
@@ -53554,14 +53592,14 @@ class Board {
53554
53592
  const items = Array.from(itemsDiv.children).map((el) => this.parseHTML(el));
53555
53593
  this.index.clear();
53556
53594
  const createdConnectors = {};
53557
- const createdFrames = {};
53595
+ const createdGroups = {};
53558
53596
  const addItem = (itemData) => {
53559
53597
  const item = this.createItem(itemData.id, itemData);
53560
53598
  if (item instanceof Connector2) {
53561
53599
  createdConnectors[itemData.id] = { item, itemData };
53562
53600
  }
53563
- if (item instanceof Frame2) {
53564
- createdFrames[item.getId()] = { item, itemData };
53601
+ if ("index" in item && item.index) {
53602
+ createdGroups[item.getId()] = { item, itemData };
53565
53603
  }
53566
53604
  this.index.insert(item);
53567
53605
  return item;
@@ -53579,8 +53617,8 @@ class Board {
53579
53617
  item.applyStartPoint(itemData.startPoint);
53580
53618
  item.applyEndPoint(itemData.endPoint);
53581
53619
  }
53582
- for (const key in createdFrames) {
53583
- const { item, itemData } = createdFrames[key];
53620
+ for (const key in createdGroups) {
53621
+ const { item, itemData } = createdGroups[key];
53584
53622
  item.applyAddChildren(itemData.children);
53585
53623
  }
53586
53624
  }
package/dist/esm/index.js CHANGED
@@ -18671,24 +18671,6 @@ class FrameCommand {
18671
18671
  ...this.operation
18672
18672
  };
18673
18673
  });
18674
- default:
18675
- return mapItemsByOperation(frame, (item) => {
18676
- const op = this.operation;
18677
- let newData = {};
18678
- if (op.prevData) {
18679
- newData = { ...op.prevData };
18680
- } else {
18681
- Object.keys(op.newData).forEach((key) => {
18682
- if (item[key]) {
18683
- newData[key] = item[key];
18684
- }
18685
- });
18686
- }
18687
- return {
18688
- ...op,
18689
- newData
18690
- };
18691
- });
18692
18674
  }
18693
18675
  }
18694
18676
  }
@@ -20668,6 +20650,11 @@ class SpatialIndex {
20668
20650
  return this.getById(item.parent);
20669
20651
  }
20670
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
+ }
20671
20658
  const index2 = this.itemsArray.indexOf(item);
20672
20659
  this.itemsArray.splice(index2, 1);
20673
20660
  this.itemsArray.splice(zIndex, 0, item);
@@ -20684,6 +20671,13 @@ class SpatialIndex {
20684
20671
  this.itemsArray.forEach(this.change.bind(this));
20685
20672
  }
20686
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
+ }
20687
20681
  const index2 = this.itemsArray.indexOf(item);
20688
20682
  this.itemsArray.splice(index2, 1);
20689
20683
  this.itemsArray.unshift(item);
@@ -20693,16 +20687,31 @@ class SpatialIndex {
20693
20687
  }
20694
20688
  }
20695
20689
  sendManyToBack(items) {
20696
- const newItems = [...items];
20697
- this.itemsArray.forEach((item) => {
20698
- if (!items.includes(item)) {
20699
- 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);
20700
20694
  }
20701
20695
  });
20702
- this.itemsArray = newItems;
20703
- 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
+ }
20704
20706
  }
20705
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
+ }
20706
20715
  const index2 = this.itemsArray.indexOf(item);
20707
20716
  this.itemsArray.splice(index2, 1);
20708
20717
  this.itemsArray.push(item);
@@ -20712,17 +20721,41 @@ class SpatialIndex {
20712
20721
  }
20713
20722
  }
20714
20723
  bringManyToFront(items) {
20715
- const newItems = [];
20716
- this.itemsArray.forEach((item) => {
20717
- if (!items.includes(item)) {
20718
- 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);
20719
20728
  }
20720
20729
  });
20721
- newItems.push(...items);
20722
- this.itemsArray = newItems;
20723
- 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;
20724
20752
  }
20725
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
+ }
20726
20759
  const secondIndex = this.itemsArray.indexOf(second);
20727
20760
  this.itemsArray.splice(secondIndex, 1);
20728
20761
  const firstIndex = this.itemsArray.indexOf(first);
@@ -20732,6 +20765,11 @@ class SpatialIndex {
20732
20765
  this.subject.publish(this.items);
20733
20766
  }
20734
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
+ }
20735
20773
  const secondIndex = this.itemsArray.indexOf(second);
20736
20774
  this.itemsArray.splice(secondIndex, 1);
20737
20775
  const firstIndex = this.itemsArray.indexOf(first);
@@ -53547,14 +53585,14 @@ class Board {
53547
53585
  const items = Array.from(itemsDiv.children).map((el) => this.parseHTML(el));
53548
53586
  this.index.clear();
53549
53587
  const createdConnectors = {};
53550
- const createdFrames = {};
53588
+ const createdGroups = {};
53551
53589
  const addItem = (itemData) => {
53552
53590
  const item = this.createItem(itemData.id, itemData);
53553
53591
  if (item instanceof Connector2) {
53554
53592
  createdConnectors[itemData.id] = { item, itemData };
53555
53593
  }
53556
- if (item instanceof Frame2) {
53557
- createdFrames[item.getId()] = { item, itemData };
53594
+ if ("index" in item && item.index) {
53595
+ createdGroups[item.getId()] = { item, itemData };
53558
53596
  }
53559
53597
  this.index.insert(item);
53560
53598
  return item;
@@ -53572,8 +53610,8 @@ class Board {
53572
53610
  item.applyStartPoint(itemData.startPoint);
53573
53611
  item.applyEndPoint(itemData.endPoint);
53574
53612
  }
53575
- for (const key in createdFrames) {
53576
- const { item, itemData } = createdFrames[key];
53613
+ for (const key in createdGroups) {
53614
+ const { item, itemData } = createdGroups[key];
53577
53615
  item.applyAddChildren(itemData.children);
53578
53616
  }
53579
53617
  }
package/dist/esm/node.js CHANGED
@@ -21206,24 +21206,6 @@ class FrameCommand {
21206
21206
  ...this.operation
21207
21207
  };
21208
21208
  });
21209
- default:
21210
- return mapItemsByOperation(frame, (item) => {
21211
- const op = this.operation;
21212
- let newData = {};
21213
- if (op.prevData) {
21214
- newData = { ...op.prevData };
21215
- } else {
21216
- Object.keys(op.newData).forEach((key) => {
21217
- if (item[key]) {
21218
- newData[key] = item[key];
21219
- }
21220
- });
21221
- }
21222
- return {
21223
- ...op,
21224
- newData
21225
- };
21226
- });
21227
21209
  }
21228
21210
  }
21229
21211
  }
@@ -23135,6 +23117,11 @@ class SpatialIndex {
23135
23117
  return this.getById(item.parent);
23136
23118
  }
23137
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
+ }
23138
23125
  const index2 = this.itemsArray.indexOf(item);
23139
23126
  this.itemsArray.splice(index2, 1);
23140
23127
  this.itemsArray.splice(zIndex, 0, item);
@@ -23151,6 +23138,13 @@ class SpatialIndex {
23151
23138
  this.itemsArray.forEach(this.change.bind(this));
23152
23139
  }
23153
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
+ }
23154
23148
  const index2 = this.itemsArray.indexOf(item);
23155
23149
  this.itemsArray.splice(index2, 1);
23156
23150
  this.itemsArray.unshift(item);
@@ -23160,16 +23154,31 @@ class SpatialIndex {
23160
23154
  }
23161
23155
  }
23162
23156
  sendManyToBack(items) {
23163
- const newItems = [...items];
23164
- this.itemsArray.forEach((item) => {
23165
- if (!items.includes(item)) {
23166
- 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);
23167
23161
  }
23168
23162
  });
23169
- this.itemsArray = newItems;
23170
- 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
+ }
23171
23173
  }
23172
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
+ }
23173
23182
  const index2 = this.itemsArray.indexOf(item);
23174
23183
  this.itemsArray.splice(index2, 1);
23175
23184
  this.itemsArray.push(item);
@@ -23179,17 +23188,41 @@ class SpatialIndex {
23179
23188
  }
23180
23189
  }
23181
23190
  bringManyToFront(items) {
23182
- const newItems = [];
23183
- this.itemsArray.forEach((item) => {
23184
- if (!items.includes(item)) {
23185
- 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);
23186
23195
  }
23187
23196
  });
23188
- newItems.push(...items);
23189
- this.itemsArray = newItems;
23190
- 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;
23191
23219
  }
23192
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
+ }
23193
23226
  const secondIndex = this.itemsArray.indexOf(second);
23194
23227
  this.itemsArray.splice(secondIndex, 1);
23195
23228
  const firstIndex = this.itemsArray.indexOf(first);
@@ -23199,6 +23232,11 @@ class SpatialIndex {
23199
23232
  this.subject.publish(this.items);
23200
23233
  }
23201
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
+ }
23202
23240
  const secondIndex = this.itemsArray.indexOf(second);
23203
23241
  this.itemsArray.splice(secondIndex, 1);
23204
23242
  const firstIndex = this.itemsArray.indexOf(first);
@@ -56015,14 +56053,14 @@ class Board {
56015
56053
  const items = Array.from(itemsDiv.children).map((el) => this.parseHTML(el));
56016
56054
  this.index.clear();
56017
56055
  const createdConnectors = {};
56018
- const createdFrames = {};
56056
+ const createdGroups = {};
56019
56057
  const addItem = (itemData) => {
56020
56058
  const item = this.createItem(itemData.id, itemData);
56021
56059
  if (item instanceof Connector2) {
56022
56060
  createdConnectors[itemData.id] = { item, itemData };
56023
56061
  }
56024
- if (item instanceof Frame2) {
56025
- createdFrames[item.getId()] = { item, itemData };
56062
+ if ("index" in item && item.index) {
56063
+ createdGroups[item.getId()] = { item, itemData };
56026
56064
  }
56027
56065
  this.index.insert(item);
56028
56066
  return item;
@@ -56040,8 +56078,8 @@ class Board {
56040
56078
  item.applyStartPoint(itemData.startPoint);
56041
56079
  item.applyEndPoint(itemData.endPoint);
56042
56080
  }
56043
- for (const key in createdFrames) {
56044
- const { item, itemData } = createdFrames[key];
56081
+ for (const key in createdGroups) {
56082
+ const { item, itemData } = createdGroups[key];
56045
56083
  item.applyAddChildren(itemData.children);
56046
56084
  }
56047
56085
  }
@@ -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.63",
3
+ "version": "0.4.65",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",