microboard-temp 0.13.13 → 0.13.15

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.
@@ -4993,6 +4993,13 @@ class BoardCommand {
4993
4993
  item: [operation.item]
4994
4994
  };
4995
4995
  }
4996
+ case "addGroup": {
4997
+ return {
4998
+ class: "Board",
4999
+ method: "removeGroup",
5000
+ item: [operation.item]
5001
+ };
5002
+ }
4996
5003
  case "removeLockedGroup": {
4997
5004
  const items = this.board.items;
4998
5005
  const reverse = [];
@@ -5010,6 +5017,23 @@ class BoardCommand {
5010
5017
  }
5011
5018
  return reverse;
5012
5019
  }
5020
+ case "removeGroup": {
5021
+ const items = this.board.items;
5022
+ const reverse = [];
5023
+ for (const itemId of operation.item) {
5024
+ const item = items.getById(itemId);
5025
+ if (!item || item.itemType !== "Group") {
5026
+ throw new Error("Get reverse board operation. Item not found");
5027
+ }
5028
+ reverse.push({
5029
+ class: "Board",
5030
+ method: "addGroup",
5031
+ item: itemId,
5032
+ data: item.serialize()
5033
+ });
5034
+ }
5035
+ return reverse;
5036
+ }
5013
5037
  case "duplicate":
5014
5038
  case "paste": {
5015
5039
  const item = [];
@@ -43613,6 +43637,7 @@ class Group extends BaseItem {
43613
43637
  transformation;
43614
43638
  subject = new Subject;
43615
43639
  transformationRenderBlock = undefined;
43640
+ isLockedGroup = false;
43616
43641
  constructor(board, events, children = [], id = "") {
43617
43642
  super(board, id, undefined, true);
43618
43643
  this.events = events;
@@ -43714,7 +43739,8 @@ class Group extends BaseItem {
43714
43739
  return {
43715
43740
  itemType: "Group",
43716
43741
  children: this.getChildrenIds(),
43717
- transformation: this.transformation.serialize()
43742
+ transformation: this.transformation.serialize(),
43743
+ isLockedGroup: this.isLockedGroup
43718
43744
  };
43719
43745
  }
43720
43746
  deserialize(data) {
@@ -43724,6 +43750,9 @@ class Group extends BaseItem {
43724
43750
  if (data.children && data.children.length > 0) {
43725
43751
  this.applyAddChildren(data.children);
43726
43752
  }
43753
+ if (data.isLockedGroup !== undefined) {
43754
+ this.isLockedGroup = data.isLockedGroup;
43755
+ }
43727
43756
  this.subject.publish(this);
43728
43757
  return this;
43729
43758
  }
@@ -43862,7 +43891,7 @@ function createGroup(id, data, board) {
43862
43891
  if (!isGroupData(data)) {
43863
43892
  throw new Error("Invalid data for Group");
43864
43893
  }
43865
- const group = new Group(board, board.events, data.children, "").setId(id).deserialize(data);
43894
+ const group = new Group(board, board.events, data.children, id).setId(id).deserialize(data);
43866
43895
  return group;
43867
43896
  }
43868
43897
  function isStickerData(data) {
@@ -54399,6 +54428,8 @@ class GravityEngine {
54399
54428
  if (this.tickTimer !== null)
54400
54429
  return;
54401
54430
  for (const item of this.board.items.listAll()) {
54431
+ const pos = item.transformation.getTranslation();
54432
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54402
54433
  this.velocities.set(item.getId(), { vx: 0, vy: 0 });
54403
54434
  }
54404
54435
  this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
@@ -54413,6 +54444,7 @@ class GravityEngine {
54413
54444
  clearInterval(this.syncTimer);
54414
54445
  this.syncTimer = null;
54415
54446
  }
54447
+ this.syncPositions();
54416
54448
  this.velocities.clear();
54417
54449
  this.lastSyncedPositions.clear();
54418
54450
  }
@@ -54675,12 +54707,17 @@ class Board {
54675
54707
  return this.applyAddItems(op);
54676
54708
  case "addLockedGroup":
54677
54709
  return this.applyAddLockedGroupOperation(op);
54710
+ case "addGroup":
54711
+ return this.applyAddGroupOperation(op);
54678
54712
  case "remove": {
54679
54713
  return this.applyRemoveOperation(op);
54680
54714
  }
54681
54715
  case "removeLockedGroup": {
54682
54716
  return this.applyRemoveLockedGroupOperation(op);
54683
54717
  }
54718
+ case "removeGroup": {
54719
+ return this.applyRemoveGroupOperation(op);
54720
+ }
54684
54721
  case "paste": {
54685
54722
  return this.applyPasteOperation(op.itemsMap);
54686
54723
  }
@@ -54718,11 +54755,23 @@ class Board {
54718
54755
  const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54719
54756
  this.index.moveToZIndex(item, zIndex);
54720
54757
  }
54758
+ item.isLockedGroup = true;
54721
54759
  item.getChildren().forEach((item2) => {
54722
54760
  item2.transformation.isLocked = true;
54723
54761
  });
54724
54762
  item.transformation.isLocked = true;
54725
54763
  }
54764
+ applyAddGroupOperation(op) {
54765
+ const item = this.createItem(op.item, op.data);
54766
+ const groupChildrenIds = item.getChildrenIds();
54767
+ this.index.insert(item);
54768
+ const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
54769
+ if (lastChildrenId) {
54770
+ const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54771
+ this.index.moveToZIndex(item, zIndex);
54772
+ }
54773
+ item.isLockedGroup = false;
54774
+ }
54726
54775
  applyRemoveOperation(op) {
54727
54776
  const removedItems = [];
54728
54777
  this.findItemAndApply(op.item, (item) => {
@@ -54751,6 +54800,21 @@ class Board {
54751
54800
  removedItems.push(item2);
54752
54801
  });
54753
54802
  }
54803
+ applyRemoveGroupOperation(op) {
54804
+ const item = this.index.getById(op.item[0]);
54805
+ if (!item || !(item instanceof Group)) {
54806
+ return;
54807
+ }
54808
+ item.getChildren().forEach((item2) => {
54809
+ item2.parent = "Board";
54810
+ });
54811
+ const removedItems = [];
54812
+ this.findItemAndApply(op.item, (item2) => {
54813
+ this.index.remove(item2);
54814
+ this.selection.remove(item2);
54815
+ removedItems.push(item2);
54816
+ });
54817
+ }
54754
54818
  applyItemOperation(op) {
54755
54819
  if ("item" in op) {
54756
54820
  this.findItemAndApply(op.item, (item) => {
@@ -54825,20 +54889,21 @@ class Board {
54825
54889
  this.handleNesting(newItem);
54826
54890
  return newItem;
54827
54891
  }
54828
- addLockedGroup(item) {
54892
+ addLockedGroup(items) {
54829
54893
  const id = this.getNewItemId();
54894
+ const groupData = {
54895
+ itemType: "Group",
54896
+ children: items.map((i) => i.getId()),
54897
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54898
+ isLockedGroup: true
54899
+ };
54830
54900
  this.emit({
54831
54901
  class: "Board",
54832
54902
  method: "addLockedGroup",
54833
54903
  item: id,
54834
- data: item.serialize()
54904
+ data: groupData
54835
54905
  });
54836
- const newItem = this.items.getById(id);
54837
- if (!newItem) {
54838
- throw new Error(`Add item. Item ${id} was not created.`);
54839
- }
54840
- this.handleNesting(newItem);
54841
- return newItem;
54906
+ return this.items.getById(id);
54842
54907
  }
54843
54908
  remove(item, withConnectors = true) {
54844
54909
  let connectors = [];
@@ -54866,11 +54931,12 @@ class Board {
54866
54931
  const groupData = {
54867
54932
  itemType: "Group",
54868
54933
  children: items.map((i) => i.getId()),
54869
- transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54934
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54935
+ isLockedGroup: false
54870
54936
  };
54871
54937
  this.emit({
54872
54938
  class: "Board",
54873
- method: "addLockedGroup",
54939
+ method: "addGroup",
54874
54940
  item: id,
54875
54941
  data: groupData
54876
54942
  });
@@ -54879,7 +54945,7 @@ class Board {
54879
54945
  ungroup(group) {
54880
54946
  this.emit({
54881
54947
  class: "Board",
54882
- method: "removeLockedGroup",
54948
+ method: "removeGroup",
54883
54949
  item: [group.getId()]
54884
54950
  });
54885
54951
  }
package/dist/cjs/index.js CHANGED
@@ -4993,6 +4993,13 @@ class BoardCommand {
4993
4993
  item: [operation.item]
4994
4994
  };
4995
4995
  }
4996
+ case "addGroup": {
4997
+ return {
4998
+ class: "Board",
4999
+ method: "removeGroup",
5000
+ item: [operation.item]
5001
+ };
5002
+ }
4996
5003
  case "removeLockedGroup": {
4997
5004
  const items = this.board.items;
4998
5005
  const reverse = [];
@@ -5010,6 +5017,23 @@ class BoardCommand {
5010
5017
  }
5011
5018
  return reverse;
5012
5019
  }
5020
+ case "removeGroup": {
5021
+ const items = this.board.items;
5022
+ const reverse = [];
5023
+ for (const itemId of operation.item) {
5024
+ const item = items.getById(itemId);
5025
+ if (!item || item.itemType !== "Group") {
5026
+ throw new Error("Get reverse board operation. Item not found");
5027
+ }
5028
+ reverse.push({
5029
+ class: "Board",
5030
+ method: "addGroup",
5031
+ item: itemId,
5032
+ data: item.serialize()
5033
+ });
5034
+ }
5035
+ return reverse;
5036
+ }
5013
5037
  case "duplicate":
5014
5038
  case "paste": {
5015
5039
  const item = [];
@@ -43613,6 +43637,7 @@ class Group extends BaseItem {
43613
43637
  transformation;
43614
43638
  subject = new Subject;
43615
43639
  transformationRenderBlock = undefined;
43640
+ isLockedGroup = false;
43616
43641
  constructor(board, events, children = [], id = "") {
43617
43642
  super(board, id, undefined, true);
43618
43643
  this.events = events;
@@ -43714,7 +43739,8 @@ class Group extends BaseItem {
43714
43739
  return {
43715
43740
  itemType: "Group",
43716
43741
  children: this.getChildrenIds(),
43717
- transformation: this.transformation.serialize()
43742
+ transformation: this.transformation.serialize(),
43743
+ isLockedGroup: this.isLockedGroup
43718
43744
  };
43719
43745
  }
43720
43746
  deserialize(data) {
@@ -43724,6 +43750,9 @@ class Group extends BaseItem {
43724
43750
  if (data.children && data.children.length > 0) {
43725
43751
  this.applyAddChildren(data.children);
43726
43752
  }
43753
+ if (data.isLockedGroup !== undefined) {
43754
+ this.isLockedGroup = data.isLockedGroup;
43755
+ }
43727
43756
  this.subject.publish(this);
43728
43757
  return this;
43729
43758
  }
@@ -43862,7 +43891,7 @@ function createGroup(id, data, board) {
43862
43891
  if (!isGroupData(data)) {
43863
43892
  throw new Error("Invalid data for Group");
43864
43893
  }
43865
- const group = new Group(board, board.events, data.children, "").setId(id).deserialize(data);
43894
+ const group = new Group(board, board.events, data.children, id).setId(id).deserialize(data);
43866
43895
  return group;
43867
43896
  }
43868
43897
  function isStickerData(data) {
@@ -54399,6 +54428,8 @@ class GravityEngine {
54399
54428
  if (this.tickTimer !== null)
54400
54429
  return;
54401
54430
  for (const item of this.board.items.listAll()) {
54431
+ const pos = item.transformation.getTranslation();
54432
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54402
54433
  this.velocities.set(item.getId(), { vx: 0, vy: 0 });
54403
54434
  }
54404
54435
  this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
@@ -54413,6 +54444,7 @@ class GravityEngine {
54413
54444
  clearInterval(this.syncTimer);
54414
54445
  this.syncTimer = null;
54415
54446
  }
54447
+ this.syncPositions();
54416
54448
  this.velocities.clear();
54417
54449
  this.lastSyncedPositions.clear();
54418
54450
  }
@@ -54675,12 +54707,17 @@ class Board {
54675
54707
  return this.applyAddItems(op);
54676
54708
  case "addLockedGroup":
54677
54709
  return this.applyAddLockedGroupOperation(op);
54710
+ case "addGroup":
54711
+ return this.applyAddGroupOperation(op);
54678
54712
  case "remove": {
54679
54713
  return this.applyRemoveOperation(op);
54680
54714
  }
54681
54715
  case "removeLockedGroup": {
54682
54716
  return this.applyRemoveLockedGroupOperation(op);
54683
54717
  }
54718
+ case "removeGroup": {
54719
+ return this.applyRemoveGroupOperation(op);
54720
+ }
54684
54721
  case "paste": {
54685
54722
  return this.applyPasteOperation(op.itemsMap);
54686
54723
  }
@@ -54718,11 +54755,23 @@ class Board {
54718
54755
  const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54719
54756
  this.index.moveToZIndex(item, zIndex);
54720
54757
  }
54758
+ item.isLockedGroup = true;
54721
54759
  item.getChildren().forEach((item2) => {
54722
54760
  item2.transformation.isLocked = true;
54723
54761
  });
54724
54762
  item.transformation.isLocked = true;
54725
54763
  }
54764
+ applyAddGroupOperation(op) {
54765
+ const item = this.createItem(op.item, op.data);
54766
+ const groupChildrenIds = item.getChildrenIds();
54767
+ this.index.insert(item);
54768
+ const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
54769
+ if (lastChildrenId) {
54770
+ const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54771
+ this.index.moveToZIndex(item, zIndex);
54772
+ }
54773
+ item.isLockedGroup = false;
54774
+ }
54726
54775
  applyRemoveOperation(op) {
54727
54776
  const removedItems = [];
54728
54777
  this.findItemAndApply(op.item, (item) => {
@@ -54751,6 +54800,21 @@ class Board {
54751
54800
  removedItems.push(item2);
54752
54801
  });
54753
54802
  }
54803
+ applyRemoveGroupOperation(op) {
54804
+ const item = this.index.getById(op.item[0]);
54805
+ if (!item || !(item instanceof Group)) {
54806
+ return;
54807
+ }
54808
+ item.getChildren().forEach((item2) => {
54809
+ item2.parent = "Board";
54810
+ });
54811
+ const removedItems = [];
54812
+ this.findItemAndApply(op.item, (item2) => {
54813
+ this.index.remove(item2);
54814
+ this.selection.remove(item2);
54815
+ removedItems.push(item2);
54816
+ });
54817
+ }
54754
54818
  applyItemOperation(op) {
54755
54819
  if ("item" in op) {
54756
54820
  this.findItemAndApply(op.item, (item) => {
@@ -54825,20 +54889,21 @@ class Board {
54825
54889
  this.handleNesting(newItem);
54826
54890
  return newItem;
54827
54891
  }
54828
- addLockedGroup(item) {
54892
+ addLockedGroup(items) {
54829
54893
  const id = this.getNewItemId();
54894
+ const groupData = {
54895
+ itemType: "Group",
54896
+ children: items.map((i) => i.getId()),
54897
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54898
+ isLockedGroup: true
54899
+ };
54830
54900
  this.emit({
54831
54901
  class: "Board",
54832
54902
  method: "addLockedGroup",
54833
54903
  item: id,
54834
- data: item.serialize()
54904
+ data: groupData
54835
54905
  });
54836
- const newItem = this.items.getById(id);
54837
- if (!newItem) {
54838
- throw new Error(`Add item. Item ${id} was not created.`);
54839
- }
54840
- this.handleNesting(newItem);
54841
- return newItem;
54906
+ return this.items.getById(id);
54842
54907
  }
54843
54908
  remove(item, withConnectors = true) {
54844
54909
  let connectors = [];
@@ -54866,11 +54931,12 @@ class Board {
54866
54931
  const groupData = {
54867
54932
  itemType: "Group",
54868
54933
  children: items.map((i) => i.getId()),
54869
- transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54934
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54935
+ isLockedGroup: false
54870
54936
  };
54871
54937
  this.emit({
54872
54938
  class: "Board",
54873
- method: "addLockedGroup",
54939
+ method: "addGroup",
54874
54940
  item: id,
54875
54941
  data: groupData
54876
54942
  });
@@ -54879,7 +54945,7 @@ class Board {
54879
54945
  ungroup(group) {
54880
54946
  this.emit({
54881
54947
  class: "Board",
54882
- method: "removeLockedGroup",
54948
+ method: "removeGroup",
54883
54949
  item: [group.getId()]
54884
54950
  });
54885
54951
  }
package/dist/cjs/node.js CHANGED
@@ -6030,6 +6030,13 @@ class BoardCommand {
6030
6030
  item: [operation.item]
6031
6031
  };
6032
6032
  }
6033
+ case "addGroup": {
6034
+ return {
6035
+ class: "Board",
6036
+ method: "removeGroup",
6037
+ item: [operation.item]
6038
+ };
6039
+ }
6033
6040
  case "removeLockedGroup": {
6034
6041
  const items = this.board.items;
6035
6042
  const reverse = [];
@@ -6047,6 +6054,23 @@ class BoardCommand {
6047
6054
  }
6048
6055
  return reverse;
6049
6056
  }
6057
+ case "removeGroup": {
6058
+ const items = this.board.items;
6059
+ const reverse = [];
6060
+ for (const itemId of operation.item) {
6061
+ const item = items.getById(itemId);
6062
+ if (!item || item.itemType !== "Group") {
6063
+ throw new Error("Get reverse board operation. Item not found");
6064
+ }
6065
+ reverse.push({
6066
+ class: "Board",
6067
+ method: "addGroup",
6068
+ item: itemId,
6069
+ data: item.serialize()
6070
+ });
6071
+ }
6072
+ return reverse;
6073
+ }
6050
6074
  case "duplicate":
6051
6075
  case "paste": {
6052
6076
  const item = [];
@@ -46086,6 +46110,7 @@ class Group extends BaseItem {
46086
46110
  transformation;
46087
46111
  subject = new Subject;
46088
46112
  transformationRenderBlock = undefined;
46113
+ isLockedGroup = false;
46089
46114
  constructor(board, events, children = [], id = "") {
46090
46115
  super(board, id, undefined, true);
46091
46116
  this.events = events;
@@ -46187,7 +46212,8 @@ class Group extends BaseItem {
46187
46212
  return {
46188
46213
  itemType: "Group",
46189
46214
  children: this.getChildrenIds(),
46190
- transformation: this.transformation.serialize()
46215
+ transformation: this.transformation.serialize(),
46216
+ isLockedGroup: this.isLockedGroup
46191
46217
  };
46192
46218
  }
46193
46219
  deserialize(data) {
@@ -46197,6 +46223,9 @@ class Group extends BaseItem {
46197
46223
  if (data.children && data.children.length > 0) {
46198
46224
  this.applyAddChildren(data.children);
46199
46225
  }
46226
+ if (data.isLockedGroup !== undefined) {
46227
+ this.isLockedGroup = data.isLockedGroup;
46228
+ }
46200
46229
  this.subject.publish(this);
46201
46230
  return this;
46202
46231
  }
@@ -46335,7 +46364,7 @@ function createGroup(id, data, board) {
46335
46364
  if (!isGroupData(data)) {
46336
46365
  throw new Error("Invalid data for Group");
46337
46366
  }
46338
- const group = new Group(board, board.events, data.children, "").setId(id).deserialize(data);
46367
+ const group = new Group(board, board.events, data.children, id).setId(id).deserialize(data);
46339
46368
  return group;
46340
46369
  }
46341
46370
  function isStickerData(data) {
@@ -56872,6 +56901,8 @@ class GravityEngine {
56872
56901
  if (this.tickTimer !== null)
56873
56902
  return;
56874
56903
  for (const item of this.board.items.listAll()) {
56904
+ const pos = item.transformation.getTranslation();
56905
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
56875
56906
  this.velocities.set(item.getId(), { vx: 0, vy: 0 });
56876
56907
  }
56877
56908
  this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
@@ -56886,6 +56917,7 @@ class GravityEngine {
56886
56917
  clearInterval(this.syncTimer);
56887
56918
  this.syncTimer = null;
56888
56919
  }
56920
+ this.syncPositions();
56889
56921
  this.velocities.clear();
56890
56922
  this.lastSyncedPositions.clear();
56891
56923
  }
@@ -57148,12 +57180,17 @@ class Board {
57148
57180
  return this.applyAddItems(op);
57149
57181
  case "addLockedGroup":
57150
57182
  return this.applyAddLockedGroupOperation(op);
57183
+ case "addGroup":
57184
+ return this.applyAddGroupOperation(op);
57151
57185
  case "remove": {
57152
57186
  return this.applyRemoveOperation(op);
57153
57187
  }
57154
57188
  case "removeLockedGroup": {
57155
57189
  return this.applyRemoveLockedGroupOperation(op);
57156
57190
  }
57191
+ case "removeGroup": {
57192
+ return this.applyRemoveGroupOperation(op);
57193
+ }
57157
57194
  case "paste": {
57158
57195
  return this.applyPasteOperation(op.itemsMap);
57159
57196
  }
@@ -57191,11 +57228,23 @@ class Board {
57191
57228
  const zIndex = this.index.getZIndex(lastChildrenId) + 1;
57192
57229
  this.index.moveToZIndex(item, zIndex);
57193
57230
  }
57231
+ item.isLockedGroup = true;
57194
57232
  item.getChildren().forEach((item2) => {
57195
57233
  item2.transformation.isLocked = true;
57196
57234
  });
57197
57235
  item.transformation.isLocked = true;
57198
57236
  }
57237
+ applyAddGroupOperation(op) {
57238
+ const item = this.createItem(op.item, op.data);
57239
+ const groupChildrenIds = item.getChildrenIds();
57240
+ this.index.insert(item);
57241
+ const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
57242
+ if (lastChildrenId) {
57243
+ const zIndex = this.index.getZIndex(lastChildrenId) + 1;
57244
+ this.index.moveToZIndex(item, zIndex);
57245
+ }
57246
+ item.isLockedGroup = false;
57247
+ }
57199
57248
  applyRemoveOperation(op) {
57200
57249
  const removedItems = [];
57201
57250
  this.findItemAndApply(op.item, (item) => {
@@ -57224,6 +57273,21 @@ class Board {
57224
57273
  removedItems.push(item2);
57225
57274
  });
57226
57275
  }
57276
+ applyRemoveGroupOperation(op) {
57277
+ const item = this.index.getById(op.item[0]);
57278
+ if (!item || !(item instanceof Group)) {
57279
+ return;
57280
+ }
57281
+ item.getChildren().forEach((item2) => {
57282
+ item2.parent = "Board";
57283
+ });
57284
+ const removedItems = [];
57285
+ this.findItemAndApply(op.item, (item2) => {
57286
+ this.index.remove(item2);
57287
+ this.selection.remove(item2);
57288
+ removedItems.push(item2);
57289
+ });
57290
+ }
57227
57291
  applyItemOperation(op) {
57228
57292
  if ("item" in op) {
57229
57293
  this.findItemAndApply(op.item, (item) => {
@@ -57298,20 +57362,21 @@ class Board {
57298
57362
  this.handleNesting(newItem);
57299
57363
  return newItem;
57300
57364
  }
57301
- addLockedGroup(item) {
57365
+ addLockedGroup(items) {
57302
57366
  const id = this.getNewItemId();
57367
+ const groupData = {
57368
+ itemType: "Group",
57369
+ children: items.map((i) => i.getId()),
57370
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
57371
+ isLockedGroup: true
57372
+ };
57303
57373
  this.emit({
57304
57374
  class: "Board",
57305
57375
  method: "addLockedGroup",
57306
57376
  item: id,
57307
- data: item.serialize()
57377
+ data: groupData
57308
57378
  });
57309
- const newItem = this.items.getById(id);
57310
- if (!newItem) {
57311
- throw new Error(`Add item. Item ${id} was not created.`);
57312
- }
57313
- this.handleNesting(newItem);
57314
- return newItem;
57379
+ return this.items.getById(id);
57315
57380
  }
57316
57381
  remove(item, withConnectors = true) {
57317
57382
  let connectors = [];
@@ -57339,11 +57404,12 @@ class Board {
57339
57404
  const groupData = {
57340
57405
  itemType: "Group",
57341
57406
  children: items.map((i) => i.getId()),
57342
- transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
57407
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
57408
+ isLockedGroup: false
57343
57409
  };
57344
57410
  this.emit({
57345
57411
  class: "Board",
57346
- method: "addLockedGroup",
57412
+ method: "addGroup",
57347
57413
  item: id,
57348
57414
  data: groupData
57349
57415
  });
@@ -57352,7 +57418,7 @@ class Board {
57352
57418
  ungroup(group) {
57353
57419
  this.emit({
57354
57420
  class: "Board",
57355
- method: "removeLockedGroup",
57421
+ method: "removeGroup",
57356
57422
  item: [group.getId()]
57357
57423
  });
57358
57424
  }
@@ -4813,6 +4813,13 @@ class BoardCommand {
4813
4813
  item: [operation.item]
4814
4814
  };
4815
4815
  }
4816
+ case "addGroup": {
4817
+ return {
4818
+ class: "Board",
4819
+ method: "removeGroup",
4820
+ item: [operation.item]
4821
+ };
4822
+ }
4816
4823
  case "removeLockedGroup": {
4817
4824
  const items = this.board.items;
4818
4825
  const reverse = [];
@@ -4830,6 +4837,23 @@ class BoardCommand {
4830
4837
  }
4831
4838
  return reverse;
4832
4839
  }
4840
+ case "removeGroup": {
4841
+ const items = this.board.items;
4842
+ const reverse = [];
4843
+ for (const itemId of operation.item) {
4844
+ const item = items.getById(itemId);
4845
+ if (!item || item.itemType !== "Group") {
4846
+ throw new Error("Get reverse board operation. Item not found");
4847
+ }
4848
+ reverse.push({
4849
+ class: "Board",
4850
+ method: "addGroup",
4851
+ item: itemId,
4852
+ data: item.serialize()
4853
+ });
4854
+ }
4855
+ return reverse;
4856
+ }
4833
4857
  case "duplicate":
4834
4858
  case "paste": {
4835
4859
  const item = [];
@@ -43442,6 +43466,7 @@ class Group extends BaseItem {
43442
43466
  transformation;
43443
43467
  subject = new Subject;
43444
43468
  transformationRenderBlock = undefined;
43469
+ isLockedGroup = false;
43445
43470
  constructor(board, events, children = [], id = "") {
43446
43471
  super(board, id, undefined, true);
43447
43472
  this.events = events;
@@ -43543,7 +43568,8 @@ class Group extends BaseItem {
43543
43568
  return {
43544
43569
  itemType: "Group",
43545
43570
  children: this.getChildrenIds(),
43546
- transformation: this.transformation.serialize()
43571
+ transformation: this.transformation.serialize(),
43572
+ isLockedGroup: this.isLockedGroup
43547
43573
  };
43548
43574
  }
43549
43575
  deserialize(data) {
@@ -43553,6 +43579,9 @@ class Group extends BaseItem {
43553
43579
  if (data.children && data.children.length > 0) {
43554
43580
  this.applyAddChildren(data.children);
43555
43581
  }
43582
+ if (data.isLockedGroup !== undefined) {
43583
+ this.isLockedGroup = data.isLockedGroup;
43584
+ }
43556
43585
  this.subject.publish(this);
43557
43586
  return this;
43558
43587
  }
@@ -43691,7 +43720,7 @@ function createGroup(id, data, board) {
43691
43720
  if (!isGroupData(data)) {
43692
43721
  throw new Error("Invalid data for Group");
43693
43722
  }
43694
- const group = new Group(board, board.events, data.children, "").setId(id).deserialize(data);
43723
+ const group = new Group(board, board.events, data.children, id).setId(id).deserialize(data);
43695
43724
  return group;
43696
43725
  }
43697
43726
  function isStickerData(data) {
@@ -54228,6 +54257,8 @@ class GravityEngine {
54228
54257
  if (this.tickTimer !== null)
54229
54258
  return;
54230
54259
  for (const item of this.board.items.listAll()) {
54260
+ const pos = item.transformation.getTranslation();
54261
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54231
54262
  this.velocities.set(item.getId(), { vx: 0, vy: 0 });
54232
54263
  }
54233
54264
  this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
@@ -54242,6 +54273,7 @@ class GravityEngine {
54242
54273
  clearInterval(this.syncTimer);
54243
54274
  this.syncTimer = null;
54244
54275
  }
54276
+ this.syncPositions();
54245
54277
  this.velocities.clear();
54246
54278
  this.lastSyncedPositions.clear();
54247
54279
  }
@@ -54504,12 +54536,17 @@ class Board {
54504
54536
  return this.applyAddItems(op);
54505
54537
  case "addLockedGroup":
54506
54538
  return this.applyAddLockedGroupOperation(op);
54539
+ case "addGroup":
54540
+ return this.applyAddGroupOperation(op);
54507
54541
  case "remove": {
54508
54542
  return this.applyRemoveOperation(op);
54509
54543
  }
54510
54544
  case "removeLockedGroup": {
54511
54545
  return this.applyRemoveLockedGroupOperation(op);
54512
54546
  }
54547
+ case "removeGroup": {
54548
+ return this.applyRemoveGroupOperation(op);
54549
+ }
54513
54550
  case "paste": {
54514
54551
  return this.applyPasteOperation(op.itemsMap);
54515
54552
  }
@@ -54547,11 +54584,23 @@ class Board {
54547
54584
  const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54548
54585
  this.index.moveToZIndex(item, zIndex);
54549
54586
  }
54587
+ item.isLockedGroup = true;
54550
54588
  item.getChildren().forEach((item2) => {
54551
54589
  item2.transformation.isLocked = true;
54552
54590
  });
54553
54591
  item.transformation.isLocked = true;
54554
54592
  }
54593
+ applyAddGroupOperation(op) {
54594
+ const item = this.createItem(op.item, op.data);
54595
+ const groupChildrenIds = item.getChildrenIds();
54596
+ this.index.insert(item);
54597
+ const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
54598
+ if (lastChildrenId) {
54599
+ const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54600
+ this.index.moveToZIndex(item, zIndex);
54601
+ }
54602
+ item.isLockedGroup = false;
54603
+ }
54555
54604
  applyRemoveOperation(op) {
54556
54605
  const removedItems = [];
54557
54606
  this.findItemAndApply(op.item, (item) => {
@@ -54580,6 +54629,21 @@ class Board {
54580
54629
  removedItems.push(item2);
54581
54630
  });
54582
54631
  }
54632
+ applyRemoveGroupOperation(op) {
54633
+ const item = this.index.getById(op.item[0]);
54634
+ if (!item || !(item instanceof Group)) {
54635
+ return;
54636
+ }
54637
+ item.getChildren().forEach((item2) => {
54638
+ item2.parent = "Board";
54639
+ });
54640
+ const removedItems = [];
54641
+ this.findItemAndApply(op.item, (item2) => {
54642
+ this.index.remove(item2);
54643
+ this.selection.remove(item2);
54644
+ removedItems.push(item2);
54645
+ });
54646
+ }
54583
54647
  applyItemOperation(op) {
54584
54648
  if ("item" in op) {
54585
54649
  this.findItemAndApply(op.item, (item) => {
@@ -54654,20 +54718,21 @@ class Board {
54654
54718
  this.handleNesting(newItem);
54655
54719
  return newItem;
54656
54720
  }
54657
- addLockedGroup(item) {
54721
+ addLockedGroup(items) {
54658
54722
  const id = this.getNewItemId();
54723
+ const groupData = {
54724
+ itemType: "Group",
54725
+ children: items.map((i) => i.getId()),
54726
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54727
+ isLockedGroup: true
54728
+ };
54659
54729
  this.emit({
54660
54730
  class: "Board",
54661
54731
  method: "addLockedGroup",
54662
54732
  item: id,
54663
- data: item.serialize()
54733
+ data: groupData
54664
54734
  });
54665
- const newItem = this.items.getById(id);
54666
- if (!newItem) {
54667
- throw new Error(`Add item. Item ${id} was not created.`);
54668
- }
54669
- this.handleNesting(newItem);
54670
- return newItem;
54735
+ return this.items.getById(id);
54671
54736
  }
54672
54737
  remove(item, withConnectors = true) {
54673
54738
  let connectors = [];
@@ -54695,11 +54760,12 @@ class Board {
54695
54760
  const groupData = {
54696
54761
  itemType: "Group",
54697
54762
  children: items.map((i) => i.getId()),
54698
- transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54763
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54764
+ isLockedGroup: false
54699
54765
  };
54700
54766
  this.emit({
54701
54767
  class: "Board",
54702
- method: "addLockedGroup",
54768
+ method: "addGroup",
54703
54769
  item: id,
54704
54770
  data: groupData
54705
54771
  });
@@ -54708,7 +54774,7 @@ class Board {
54708
54774
  ungroup(group) {
54709
54775
  this.emit({
54710
54776
  class: "Board",
54711
- method: "removeLockedGroup",
54777
+ method: "removeGroup",
54712
54778
  item: [group.getId()]
54713
54779
  });
54714
54780
  }
package/dist/esm/index.js CHANGED
@@ -4806,6 +4806,13 @@ class BoardCommand {
4806
4806
  item: [operation.item]
4807
4807
  };
4808
4808
  }
4809
+ case "addGroup": {
4810
+ return {
4811
+ class: "Board",
4812
+ method: "removeGroup",
4813
+ item: [operation.item]
4814
+ };
4815
+ }
4809
4816
  case "removeLockedGroup": {
4810
4817
  const items = this.board.items;
4811
4818
  const reverse = [];
@@ -4823,6 +4830,23 @@ class BoardCommand {
4823
4830
  }
4824
4831
  return reverse;
4825
4832
  }
4833
+ case "removeGroup": {
4834
+ const items = this.board.items;
4835
+ const reverse = [];
4836
+ for (const itemId of operation.item) {
4837
+ const item = items.getById(itemId);
4838
+ if (!item || item.itemType !== "Group") {
4839
+ throw new Error("Get reverse board operation. Item not found");
4840
+ }
4841
+ reverse.push({
4842
+ class: "Board",
4843
+ method: "addGroup",
4844
+ item: itemId,
4845
+ data: item.serialize()
4846
+ });
4847
+ }
4848
+ return reverse;
4849
+ }
4826
4850
  case "duplicate":
4827
4851
  case "paste": {
4828
4852
  const item = [];
@@ -43435,6 +43459,7 @@ class Group extends BaseItem {
43435
43459
  transformation;
43436
43460
  subject = new Subject;
43437
43461
  transformationRenderBlock = undefined;
43462
+ isLockedGroup = false;
43438
43463
  constructor(board, events, children = [], id = "") {
43439
43464
  super(board, id, undefined, true);
43440
43465
  this.events = events;
@@ -43536,7 +43561,8 @@ class Group extends BaseItem {
43536
43561
  return {
43537
43562
  itemType: "Group",
43538
43563
  children: this.getChildrenIds(),
43539
- transformation: this.transformation.serialize()
43564
+ transformation: this.transformation.serialize(),
43565
+ isLockedGroup: this.isLockedGroup
43540
43566
  };
43541
43567
  }
43542
43568
  deserialize(data) {
@@ -43546,6 +43572,9 @@ class Group extends BaseItem {
43546
43572
  if (data.children && data.children.length > 0) {
43547
43573
  this.applyAddChildren(data.children);
43548
43574
  }
43575
+ if (data.isLockedGroup !== undefined) {
43576
+ this.isLockedGroup = data.isLockedGroup;
43577
+ }
43549
43578
  this.subject.publish(this);
43550
43579
  return this;
43551
43580
  }
@@ -43684,7 +43713,7 @@ function createGroup(id, data, board) {
43684
43713
  if (!isGroupData(data)) {
43685
43714
  throw new Error("Invalid data for Group");
43686
43715
  }
43687
- const group = new Group(board, board.events, data.children, "").setId(id).deserialize(data);
43716
+ const group = new Group(board, board.events, data.children, id).setId(id).deserialize(data);
43688
43717
  return group;
43689
43718
  }
43690
43719
  function isStickerData(data) {
@@ -54221,6 +54250,8 @@ class GravityEngine {
54221
54250
  if (this.tickTimer !== null)
54222
54251
  return;
54223
54252
  for (const item of this.board.items.listAll()) {
54253
+ const pos = item.transformation.getTranslation();
54254
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54224
54255
  this.velocities.set(item.getId(), { vx: 0, vy: 0 });
54225
54256
  }
54226
54257
  this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
@@ -54235,6 +54266,7 @@ class GravityEngine {
54235
54266
  clearInterval(this.syncTimer);
54236
54267
  this.syncTimer = null;
54237
54268
  }
54269
+ this.syncPositions();
54238
54270
  this.velocities.clear();
54239
54271
  this.lastSyncedPositions.clear();
54240
54272
  }
@@ -54497,12 +54529,17 @@ class Board {
54497
54529
  return this.applyAddItems(op);
54498
54530
  case "addLockedGroup":
54499
54531
  return this.applyAddLockedGroupOperation(op);
54532
+ case "addGroup":
54533
+ return this.applyAddGroupOperation(op);
54500
54534
  case "remove": {
54501
54535
  return this.applyRemoveOperation(op);
54502
54536
  }
54503
54537
  case "removeLockedGroup": {
54504
54538
  return this.applyRemoveLockedGroupOperation(op);
54505
54539
  }
54540
+ case "removeGroup": {
54541
+ return this.applyRemoveGroupOperation(op);
54542
+ }
54506
54543
  case "paste": {
54507
54544
  return this.applyPasteOperation(op.itemsMap);
54508
54545
  }
@@ -54540,11 +54577,23 @@ class Board {
54540
54577
  const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54541
54578
  this.index.moveToZIndex(item, zIndex);
54542
54579
  }
54580
+ item.isLockedGroup = true;
54543
54581
  item.getChildren().forEach((item2) => {
54544
54582
  item2.transformation.isLocked = true;
54545
54583
  });
54546
54584
  item.transformation.isLocked = true;
54547
54585
  }
54586
+ applyAddGroupOperation(op) {
54587
+ const item = this.createItem(op.item, op.data);
54588
+ const groupChildrenIds = item.getChildrenIds();
54589
+ this.index.insert(item);
54590
+ const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
54591
+ if (lastChildrenId) {
54592
+ const zIndex = this.index.getZIndex(lastChildrenId) + 1;
54593
+ this.index.moveToZIndex(item, zIndex);
54594
+ }
54595
+ item.isLockedGroup = false;
54596
+ }
54548
54597
  applyRemoveOperation(op) {
54549
54598
  const removedItems = [];
54550
54599
  this.findItemAndApply(op.item, (item) => {
@@ -54573,6 +54622,21 @@ class Board {
54573
54622
  removedItems.push(item2);
54574
54623
  });
54575
54624
  }
54625
+ applyRemoveGroupOperation(op) {
54626
+ const item = this.index.getById(op.item[0]);
54627
+ if (!item || !(item instanceof Group)) {
54628
+ return;
54629
+ }
54630
+ item.getChildren().forEach((item2) => {
54631
+ item2.parent = "Board";
54632
+ });
54633
+ const removedItems = [];
54634
+ this.findItemAndApply(op.item, (item2) => {
54635
+ this.index.remove(item2);
54636
+ this.selection.remove(item2);
54637
+ removedItems.push(item2);
54638
+ });
54639
+ }
54576
54640
  applyItemOperation(op) {
54577
54641
  if ("item" in op) {
54578
54642
  this.findItemAndApply(op.item, (item) => {
@@ -54647,20 +54711,21 @@ class Board {
54647
54711
  this.handleNesting(newItem);
54648
54712
  return newItem;
54649
54713
  }
54650
- addLockedGroup(item) {
54714
+ addLockedGroup(items) {
54651
54715
  const id = this.getNewItemId();
54716
+ const groupData = {
54717
+ itemType: "Group",
54718
+ children: items.map((i) => i.getId()),
54719
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54720
+ isLockedGroup: true
54721
+ };
54652
54722
  this.emit({
54653
54723
  class: "Board",
54654
54724
  method: "addLockedGroup",
54655
54725
  item: id,
54656
- data: item.serialize()
54726
+ data: groupData
54657
54727
  });
54658
- const newItem = this.items.getById(id);
54659
- if (!newItem) {
54660
- throw new Error(`Add item. Item ${id} was not created.`);
54661
- }
54662
- this.handleNesting(newItem);
54663
- return newItem;
54728
+ return this.items.getById(id);
54664
54729
  }
54665
54730
  remove(item, withConnectors = true) {
54666
54731
  let connectors = [];
@@ -54688,11 +54753,12 @@ class Board {
54688
54753
  const groupData = {
54689
54754
  itemType: "Group",
54690
54755
  children: items.map((i) => i.getId()),
54691
- transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
54756
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
54757
+ isLockedGroup: false
54692
54758
  };
54693
54759
  this.emit({
54694
54760
  class: "Board",
54695
- method: "addLockedGroup",
54761
+ method: "addGroup",
54696
54762
  item: id,
54697
54763
  data: groupData
54698
54764
  });
@@ -54701,7 +54767,7 @@ class Board {
54701
54767
  ungroup(group) {
54702
54768
  this.emit({
54703
54769
  class: "Board",
54704
- method: "removeLockedGroup",
54770
+ method: "removeGroup",
54705
54771
  item: [group.getId()]
54706
54772
  });
54707
54773
  }
package/dist/esm/node.js CHANGED
@@ -5590,6 +5590,13 @@ class BoardCommand {
5590
5590
  item: [operation.item]
5591
5591
  };
5592
5592
  }
5593
+ case "addGroup": {
5594
+ return {
5595
+ class: "Board",
5596
+ method: "removeGroup",
5597
+ item: [operation.item]
5598
+ };
5599
+ }
5593
5600
  case "removeLockedGroup": {
5594
5601
  const items = this.board.items;
5595
5602
  const reverse = [];
@@ -5607,6 +5614,23 @@ class BoardCommand {
5607
5614
  }
5608
5615
  return reverse;
5609
5616
  }
5617
+ case "removeGroup": {
5618
+ const items = this.board.items;
5619
+ const reverse = [];
5620
+ for (const itemId of operation.item) {
5621
+ const item = items.getById(itemId);
5622
+ if (!item || item.itemType !== "Group") {
5623
+ throw new Error("Get reverse board operation. Item not found");
5624
+ }
5625
+ reverse.push({
5626
+ class: "Board",
5627
+ method: "addGroup",
5628
+ item: itemId,
5629
+ data: item.serialize()
5630
+ });
5631
+ }
5632
+ return reverse;
5633
+ }
5610
5634
  case "duplicate":
5611
5635
  case "paste": {
5612
5636
  const item = [];
@@ -45903,6 +45927,7 @@ class Group extends BaseItem {
45903
45927
  transformation;
45904
45928
  subject = new Subject;
45905
45929
  transformationRenderBlock = undefined;
45930
+ isLockedGroup = false;
45906
45931
  constructor(board, events, children = [], id = "") {
45907
45932
  super(board, id, undefined, true);
45908
45933
  this.events = events;
@@ -46004,7 +46029,8 @@ class Group extends BaseItem {
46004
46029
  return {
46005
46030
  itemType: "Group",
46006
46031
  children: this.getChildrenIds(),
46007
- transformation: this.transformation.serialize()
46032
+ transformation: this.transformation.serialize(),
46033
+ isLockedGroup: this.isLockedGroup
46008
46034
  };
46009
46035
  }
46010
46036
  deserialize(data) {
@@ -46014,6 +46040,9 @@ class Group extends BaseItem {
46014
46040
  if (data.children && data.children.length > 0) {
46015
46041
  this.applyAddChildren(data.children);
46016
46042
  }
46043
+ if (data.isLockedGroup !== undefined) {
46044
+ this.isLockedGroup = data.isLockedGroup;
46045
+ }
46017
46046
  this.subject.publish(this);
46018
46047
  return this;
46019
46048
  }
@@ -46152,7 +46181,7 @@ function createGroup(id, data, board) {
46152
46181
  if (!isGroupData(data)) {
46153
46182
  throw new Error("Invalid data for Group");
46154
46183
  }
46155
- const group = new Group(board, board.events, data.children, "").setId(id).deserialize(data);
46184
+ const group = new Group(board, board.events, data.children, id).setId(id).deserialize(data);
46156
46185
  return group;
46157
46186
  }
46158
46187
  function isStickerData(data) {
@@ -56689,6 +56718,8 @@ class GravityEngine {
56689
56718
  if (this.tickTimer !== null)
56690
56719
  return;
56691
56720
  for (const item of this.board.items.listAll()) {
56721
+ const pos = item.transformation.getTranslation();
56722
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
56692
56723
  this.velocities.set(item.getId(), { vx: 0, vy: 0 });
56693
56724
  }
56694
56725
  this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
@@ -56703,6 +56734,7 @@ class GravityEngine {
56703
56734
  clearInterval(this.syncTimer);
56704
56735
  this.syncTimer = null;
56705
56736
  }
56737
+ this.syncPositions();
56706
56738
  this.velocities.clear();
56707
56739
  this.lastSyncedPositions.clear();
56708
56740
  }
@@ -56965,12 +56997,17 @@ class Board {
56965
56997
  return this.applyAddItems(op);
56966
56998
  case "addLockedGroup":
56967
56999
  return this.applyAddLockedGroupOperation(op);
57000
+ case "addGroup":
57001
+ return this.applyAddGroupOperation(op);
56968
57002
  case "remove": {
56969
57003
  return this.applyRemoveOperation(op);
56970
57004
  }
56971
57005
  case "removeLockedGroup": {
56972
57006
  return this.applyRemoveLockedGroupOperation(op);
56973
57007
  }
57008
+ case "removeGroup": {
57009
+ return this.applyRemoveGroupOperation(op);
57010
+ }
56974
57011
  case "paste": {
56975
57012
  return this.applyPasteOperation(op.itemsMap);
56976
57013
  }
@@ -57008,11 +57045,23 @@ class Board {
57008
57045
  const zIndex = this.index.getZIndex(lastChildrenId) + 1;
57009
57046
  this.index.moveToZIndex(item, zIndex);
57010
57047
  }
57048
+ item.isLockedGroup = true;
57011
57049
  item.getChildren().forEach((item2) => {
57012
57050
  item2.transformation.isLocked = true;
57013
57051
  });
57014
57052
  item.transformation.isLocked = true;
57015
57053
  }
57054
+ applyAddGroupOperation(op) {
57055
+ const item = this.createItem(op.item, op.data);
57056
+ const groupChildrenIds = item.getChildrenIds();
57057
+ this.index.insert(item);
57058
+ const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
57059
+ if (lastChildrenId) {
57060
+ const zIndex = this.index.getZIndex(lastChildrenId) + 1;
57061
+ this.index.moveToZIndex(item, zIndex);
57062
+ }
57063
+ item.isLockedGroup = false;
57064
+ }
57016
57065
  applyRemoveOperation(op) {
57017
57066
  const removedItems = [];
57018
57067
  this.findItemAndApply(op.item, (item) => {
@@ -57041,6 +57090,21 @@ class Board {
57041
57090
  removedItems.push(item2);
57042
57091
  });
57043
57092
  }
57093
+ applyRemoveGroupOperation(op) {
57094
+ const item = this.index.getById(op.item[0]);
57095
+ if (!item || !(item instanceof Group)) {
57096
+ return;
57097
+ }
57098
+ item.getChildren().forEach((item2) => {
57099
+ item2.parent = "Board";
57100
+ });
57101
+ const removedItems = [];
57102
+ this.findItemAndApply(op.item, (item2) => {
57103
+ this.index.remove(item2);
57104
+ this.selection.remove(item2);
57105
+ removedItems.push(item2);
57106
+ });
57107
+ }
57044
57108
  applyItemOperation(op) {
57045
57109
  if ("item" in op) {
57046
57110
  this.findItemAndApply(op.item, (item) => {
@@ -57115,20 +57179,21 @@ class Board {
57115
57179
  this.handleNesting(newItem);
57116
57180
  return newItem;
57117
57181
  }
57118
- addLockedGroup(item) {
57182
+ addLockedGroup(items) {
57119
57183
  const id = this.getNewItemId();
57184
+ const groupData = {
57185
+ itemType: "Group",
57186
+ children: items.map((i) => i.getId()),
57187
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
57188
+ isLockedGroup: true
57189
+ };
57120
57190
  this.emit({
57121
57191
  class: "Board",
57122
57192
  method: "addLockedGroup",
57123
57193
  item: id,
57124
- data: item.serialize()
57194
+ data: groupData
57125
57195
  });
57126
- const newItem = this.items.getById(id);
57127
- if (!newItem) {
57128
- throw new Error(`Add item. Item ${id} was not created.`);
57129
- }
57130
- this.handleNesting(newItem);
57131
- return newItem;
57196
+ return this.items.getById(id);
57132
57197
  }
57133
57198
  remove(item, withConnectors = true) {
57134
57199
  let connectors = [];
@@ -57156,11 +57221,12 @@ class Board {
57156
57221
  const groupData = {
57157
57222
  itemType: "Group",
57158
57223
  children: items.map((i) => i.getId()),
57159
- transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
57224
+ transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
57225
+ isLockedGroup: false
57160
57226
  };
57161
57227
  this.emit({
57162
57228
  class: "Board",
57163
- method: "addLockedGroup",
57229
+ method: "addGroup",
57164
57230
  item: id,
57165
57231
  data: groupData
57166
57232
  });
@@ -57169,7 +57235,7 @@ class Board {
57169
57235
  ungroup(group) {
57170
57236
  this.emit({
57171
57237
  class: "Board",
57172
- method: "removeLockedGroup",
57238
+ method: "removeGroup",
57173
57239
  item: [group.getId()]
57174
57240
  });
57175
57241
  }
@@ -62,8 +62,10 @@ export declare class Board {
62
62
  private applyBoardOperation;
63
63
  private applyAddItems;
64
64
  private applyAddLockedGroupOperation;
65
+ private applyAddGroupOperation;
65
66
  private applyRemoveOperation;
66
67
  private applyRemoveLockedGroupOperation;
68
+ private applyRemoveGroupOperation;
67
69
  private applyItemOperation;
68
70
  private findItemAndApply;
69
71
  /** Nest item to the frame which is seen on the screen and covers the most volume of the item
@@ -77,7 +79,7 @@ export declare class Board {
77
79
  };
78
80
  };
79
81
  add<T extends Item>(item: T, timeStamp?: number): T;
80
- addLockedGroup(item: Group): Item;
82
+ addLockedGroup(items: BaseItem[]): Group;
81
83
  remove(item: Item, withConnectors?: boolean): void;
82
84
  removeLockedGroup(item: Group): void;
83
85
  /**
@@ -29,6 +29,10 @@ export interface CreateLockedGroupItem extends SingleItemBoardOp {
29
29
  method: "addLockedGroup";
30
30
  data: GroupData;
31
31
  }
32
+ export interface CreateGroup extends SingleItemBoardOp {
33
+ method: "addGroup";
34
+ data: GroupData;
35
+ }
32
36
  export interface RemoveItem extends MultiItemBoardOp {
33
37
  method: "remove";
34
38
  }
@@ -41,6 +45,9 @@ export interface UnlockItem extends MultiItemBoardOp {
41
45
  export interface RemoveLockedGroup extends MultiItemBoardOp {
42
46
  method: "removeLockedGroup";
43
47
  }
48
+ export interface RemoveGroup extends MultiItemBoardOp {
49
+ method: "removeGroup";
50
+ }
44
51
  interface MoveToZIndex extends SingleItemBoardOp {
45
52
  method: "moveToZIndex";
46
53
  zIndex: number;
@@ -72,5 +79,5 @@ interface Paste extends ItemMapBoardOp {
72
79
  interface Duplicate extends ItemMapBoardOp {
73
80
  method: "duplicate";
74
81
  }
75
- export type BoardOps = CreateItem | CreateLockedGroupItem | RemoveItem | RemoveLockedGroup | MoveToZIndex | MoveManyToZIndex | MoveSecondBeforeFirst | MoveSecondAfterFirst | BringToFront | SendToBack | Paste | Duplicate | LockItem | UnlockItem;
82
+ export type BoardOps = CreateItem | CreateLockedGroupItem | CreateGroup | RemoveItem | RemoveLockedGroup | RemoveGroup | MoveToZIndex | MoveManyToZIndex | MoveSecondBeforeFirst | MoveSecondAfterFirst | BringToFront | SendToBack | Paste | Duplicate | LockItem | UnlockItem;
76
83
  export {};
@@ -12,6 +12,7 @@ export interface GroupData {
12
12
  readonly itemType: "Group";
13
13
  children: string[];
14
14
  transformation: TransformationData;
15
+ isLockedGroup?: boolean;
15
16
  }
16
17
  export declare class Group extends BaseItem {
17
18
  private events?;
@@ -21,6 +22,7 @@ export declare class Group extends BaseItem {
21
22
  readonly transformation: Transformation;
22
23
  readonly subject: Subject<Group>;
23
24
  transformationRenderBlock?: boolean;
25
+ isLockedGroup: boolean;
24
26
  constructor(board: Board, events?: Events | undefined, children?: string[], id?: string);
25
27
  isClosed(): boolean;
26
28
  getRichText(): null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.13",
3
+ "version": "0.13.15",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",