microboard-temp 0.13.13 → 0.13.14
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.
- package/dist/cjs/browser.js +76 -13
- package/dist/cjs/index.js +76 -13
- package/dist/cjs/node.js +76 -13
- package/dist/esm/browser.js +76 -13
- package/dist/esm/index.js +76 -13
- package/dist/esm/node.js +76 -13
- package/dist/types/Board.d.ts +3 -1
- package/dist/types/BoardOperations.d.ts +8 -1
- package/dist/types/Items/Group/Group.d.ts +2 -0
- package/package.json +1 -1
package/dist/cjs/browser.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,
|
|
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) {
|
|
@@ -54675,12 +54704,17 @@ class Board {
|
|
|
54675
54704
|
return this.applyAddItems(op);
|
|
54676
54705
|
case "addLockedGroup":
|
|
54677
54706
|
return this.applyAddLockedGroupOperation(op);
|
|
54707
|
+
case "addGroup":
|
|
54708
|
+
return this.applyAddGroupOperation(op);
|
|
54678
54709
|
case "remove": {
|
|
54679
54710
|
return this.applyRemoveOperation(op);
|
|
54680
54711
|
}
|
|
54681
54712
|
case "removeLockedGroup": {
|
|
54682
54713
|
return this.applyRemoveLockedGroupOperation(op);
|
|
54683
54714
|
}
|
|
54715
|
+
case "removeGroup": {
|
|
54716
|
+
return this.applyRemoveGroupOperation(op);
|
|
54717
|
+
}
|
|
54684
54718
|
case "paste": {
|
|
54685
54719
|
return this.applyPasteOperation(op.itemsMap);
|
|
54686
54720
|
}
|
|
@@ -54718,11 +54752,23 @@ class Board {
|
|
|
54718
54752
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54719
54753
|
this.index.moveToZIndex(item, zIndex);
|
|
54720
54754
|
}
|
|
54755
|
+
item.isLockedGroup = true;
|
|
54721
54756
|
item.getChildren().forEach((item2) => {
|
|
54722
54757
|
item2.transformation.isLocked = true;
|
|
54723
54758
|
});
|
|
54724
54759
|
item.transformation.isLocked = true;
|
|
54725
54760
|
}
|
|
54761
|
+
applyAddGroupOperation(op) {
|
|
54762
|
+
const item = this.createItem(op.item, op.data);
|
|
54763
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
54764
|
+
this.index.insert(item);
|
|
54765
|
+
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
54766
|
+
if (lastChildrenId) {
|
|
54767
|
+
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54768
|
+
this.index.moveToZIndex(item, zIndex);
|
|
54769
|
+
}
|
|
54770
|
+
item.isLockedGroup = false;
|
|
54771
|
+
}
|
|
54726
54772
|
applyRemoveOperation(op) {
|
|
54727
54773
|
const removedItems = [];
|
|
54728
54774
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54751,6 +54797,21 @@ class Board {
|
|
|
54751
54797
|
removedItems.push(item2);
|
|
54752
54798
|
});
|
|
54753
54799
|
}
|
|
54800
|
+
applyRemoveGroupOperation(op) {
|
|
54801
|
+
const item = this.index.getById(op.item[0]);
|
|
54802
|
+
if (!item || !(item instanceof Group)) {
|
|
54803
|
+
return;
|
|
54804
|
+
}
|
|
54805
|
+
item.getChildren().forEach((item2) => {
|
|
54806
|
+
item2.parent = "Board";
|
|
54807
|
+
});
|
|
54808
|
+
const removedItems = [];
|
|
54809
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
54810
|
+
this.index.remove(item2);
|
|
54811
|
+
this.selection.remove(item2);
|
|
54812
|
+
removedItems.push(item2);
|
|
54813
|
+
});
|
|
54814
|
+
}
|
|
54754
54815
|
applyItemOperation(op) {
|
|
54755
54816
|
if ("item" in op) {
|
|
54756
54817
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54825,20 +54886,21 @@ class Board {
|
|
|
54825
54886
|
this.handleNesting(newItem);
|
|
54826
54887
|
return newItem;
|
|
54827
54888
|
}
|
|
54828
|
-
addLockedGroup(
|
|
54889
|
+
addLockedGroup(items) {
|
|
54829
54890
|
const id = this.getNewItemId();
|
|
54891
|
+
const groupData = {
|
|
54892
|
+
itemType: "Group",
|
|
54893
|
+
children: items.map((i) => i.getId()),
|
|
54894
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54895
|
+
isLockedGroup: true
|
|
54896
|
+
};
|
|
54830
54897
|
this.emit({
|
|
54831
54898
|
class: "Board",
|
|
54832
54899
|
method: "addLockedGroup",
|
|
54833
54900
|
item: id,
|
|
54834
|
-
data:
|
|
54901
|
+
data: groupData
|
|
54835
54902
|
});
|
|
54836
|
-
|
|
54837
|
-
if (!newItem) {
|
|
54838
|
-
throw new Error(`Add item. Item ${id} was not created.`);
|
|
54839
|
-
}
|
|
54840
|
-
this.handleNesting(newItem);
|
|
54841
|
-
return newItem;
|
|
54903
|
+
return this.items.getById(id);
|
|
54842
54904
|
}
|
|
54843
54905
|
remove(item, withConnectors = true) {
|
|
54844
54906
|
let connectors = [];
|
|
@@ -54866,11 +54928,12 @@ class Board {
|
|
|
54866
54928
|
const groupData = {
|
|
54867
54929
|
itemType: "Group",
|
|
54868
54930
|
children: items.map((i) => i.getId()),
|
|
54869
|
-
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1,
|
|
54931
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54932
|
+
isLockedGroup: false
|
|
54870
54933
|
};
|
|
54871
54934
|
this.emit({
|
|
54872
54935
|
class: "Board",
|
|
54873
|
-
method: "
|
|
54936
|
+
method: "addGroup",
|
|
54874
54937
|
item: id,
|
|
54875
54938
|
data: groupData
|
|
54876
54939
|
});
|
|
@@ -54879,7 +54942,7 @@ class Board {
|
|
|
54879
54942
|
ungroup(group) {
|
|
54880
54943
|
this.emit({
|
|
54881
54944
|
class: "Board",
|
|
54882
|
-
method: "
|
|
54945
|
+
method: "removeGroup",
|
|
54883
54946
|
item: [group.getId()]
|
|
54884
54947
|
});
|
|
54885
54948
|
}
|
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,
|
|
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) {
|
|
@@ -54675,12 +54704,17 @@ class Board {
|
|
|
54675
54704
|
return this.applyAddItems(op);
|
|
54676
54705
|
case "addLockedGroup":
|
|
54677
54706
|
return this.applyAddLockedGroupOperation(op);
|
|
54707
|
+
case "addGroup":
|
|
54708
|
+
return this.applyAddGroupOperation(op);
|
|
54678
54709
|
case "remove": {
|
|
54679
54710
|
return this.applyRemoveOperation(op);
|
|
54680
54711
|
}
|
|
54681
54712
|
case "removeLockedGroup": {
|
|
54682
54713
|
return this.applyRemoveLockedGroupOperation(op);
|
|
54683
54714
|
}
|
|
54715
|
+
case "removeGroup": {
|
|
54716
|
+
return this.applyRemoveGroupOperation(op);
|
|
54717
|
+
}
|
|
54684
54718
|
case "paste": {
|
|
54685
54719
|
return this.applyPasteOperation(op.itemsMap);
|
|
54686
54720
|
}
|
|
@@ -54718,11 +54752,23 @@ class Board {
|
|
|
54718
54752
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54719
54753
|
this.index.moveToZIndex(item, zIndex);
|
|
54720
54754
|
}
|
|
54755
|
+
item.isLockedGroup = true;
|
|
54721
54756
|
item.getChildren().forEach((item2) => {
|
|
54722
54757
|
item2.transformation.isLocked = true;
|
|
54723
54758
|
});
|
|
54724
54759
|
item.transformation.isLocked = true;
|
|
54725
54760
|
}
|
|
54761
|
+
applyAddGroupOperation(op) {
|
|
54762
|
+
const item = this.createItem(op.item, op.data);
|
|
54763
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
54764
|
+
this.index.insert(item);
|
|
54765
|
+
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
54766
|
+
if (lastChildrenId) {
|
|
54767
|
+
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54768
|
+
this.index.moveToZIndex(item, zIndex);
|
|
54769
|
+
}
|
|
54770
|
+
item.isLockedGroup = false;
|
|
54771
|
+
}
|
|
54726
54772
|
applyRemoveOperation(op) {
|
|
54727
54773
|
const removedItems = [];
|
|
54728
54774
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54751,6 +54797,21 @@ class Board {
|
|
|
54751
54797
|
removedItems.push(item2);
|
|
54752
54798
|
});
|
|
54753
54799
|
}
|
|
54800
|
+
applyRemoveGroupOperation(op) {
|
|
54801
|
+
const item = this.index.getById(op.item[0]);
|
|
54802
|
+
if (!item || !(item instanceof Group)) {
|
|
54803
|
+
return;
|
|
54804
|
+
}
|
|
54805
|
+
item.getChildren().forEach((item2) => {
|
|
54806
|
+
item2.parent = "Board";
|
|
54807
|
+
});
|
|
54808
|
+
const removedItems = [];
|
|
54809
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
54810
|
+
this.index.remove(item2);
|
|
54811
|
+
this.selection.remove(item2);
|
|
54812
|
+
removedItems.push(item2);
|
|
54813
|
+
});
|
|
54814
|
+
}
|
|
54754
54815
|
applyItemOperation(op) {
|
|
54755
54816
|
if ("item" in op) {
|
|
54756
54817
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54825,20 +54886,21 @@ class Board {
|
|
|
54825
54886
|
this.handleNesting(newItem);
|
|
54826
54887
|
return newItem;
|
|
54827
54888
|
}
|
|
54828
|
-
addLockedGroup(
|
|
54889
|
+
addLockedGroup(items) {
|
|
54829
54890
|
const id = this.getNewItemId();
|
|
54891
|
+
const groupData = {
|
|
54892
|
+
itemType: "Group",
|
|
54893
|
+
children: items.map((i) => i.getId()),
|
|
54894
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54895
|
+
isLockedGroup: true
|
|
54896
|
+
};
|
|
54830
54897
|
this.emit({
|
|
54831
54898
|
class: "Board",
|
|
54832
54899
|
method: "addLockedGroup",
|
|
54833
54900
|
item: id,
|
|
54834
|
-
data:
|
|
54901
|
+
data: groupData
|
|
54835
54902
|
});
|
|
54836
|
-
|
|
54837
|
-
if (!newItem) {
|
|
54838
|
-
throw new Error(`Add item. Item ${id} was not created.`);
|
|
54839
|
-
}
|
|
54840
|
-
this.handleNesting(newItem);
|
|
54841
|
-
return newItem;
|
|
54903
|
+
return this.items.getById(id);
|
|
54842
54904
|
}
|
|
54843
54905
|
remove(item, withConnectors = true) {
|
|
54844
54906
|
let connectors = [];
|
|
@@ -54866,11 +54928,12 @@ class Board {
|
|
|
54866
54928
|
const groupData = {
|
|
54867
54929
|
itemType: "Group",
|
|
54868
54930
|
children: items.map((i) => i.getId()),
|
|
54869
|
-
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1,
|
|
54931
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54932
|
+
isLockedGroup: false
|
|
54870
54933
|
};
|
|
54871
54934
|
this.emit({
|
|
54872
54935
|
class: "Board",
|
|
54873
|
-
method: "
|
|
54936
|
+
method: "addGroup",
|
|
54874
54937
|
item: id,
|
|
54875
54938
|
data: groupData
|
|
54876
54939
|
});
|
|
@@ -54879,7 +54942,7 @@ class Board {
|
|
|
54879
54942
|
ungroup(group) {
|
|
54880
54943
|
this.emit({
|
|
54881
54944
|
class: "Board",
|
|
54882
|
-
method: "
|
|
54945
|
+
method: "removeGroup",
|
|
54883
54946
|
item: [group.getId()]
|
|
54884
54947
|
});
|
|
54885
54948
|
}
|
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,
|
|
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) {
|
|
@@ -57148,12 +57177,17 @@ class Board {
|
|
|
57148
57177
|
return this.applyAddItems(op);
|
|
57149
57178
|
case "addLockedGroup":
|
|
57150
57179
|
return this.applyAddLockedGroupOperation(op);
|
|
57180
|
+
case "addGroup":
|
|
57181
|
+
return this.applyAddGroupOperation(op);
|
|
57151
57182
|
case "remove": {
|
|
57152
57183
|
return this.applyRemoveOperation(op);
|
|
57153
57184
|
}
|
|
57154
57185
|
case "removeLockedGroup": {
|
|
57155
57186
|
return this.applyRemoveLockedGroupOperation(op);
|
|
57156
57187
|
}
|
|
57188
|
+
case "removeGroup": {
|
|
57189
|
+
return this.applyRemoveGroupOperation(op);
|
|
57190
|
+
}
|
|
57157
57191
|
case "paste": {
|
|
57158
57192
|
return this.applyPasteOperation(op.itemsMap);
|
|
57159
57193
|
}
|
|
@@ -57191,11 +57225,23 @@ class Board {
|
|
|
57191
57225
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
57192
57226
|
this.index.moveToZIndex(item, zIndex);
|
|
57193
57227
|
}
|
|
57228
|
+
item.isLockedGroup = true;
|
|
57194
57229
|
item.getChildren().forEach((item2) => {
|
|
57195
57230
|
item2.transformation.isLocked = true;
|
|
57196
57231
|
});
|
|
57197
57232
|
item.transformation.isLocked = true;
|
|
57198
57233
|
}
|
|
57234
|
+
applyAddGroupOperation(op) {
|
|
57235
|
+
const item = this.createItem(op.item, op.data);
|
|
57236
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
57237
|
+
this.index.insert(item);
|
|
57238
|
+
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
57239
|
+
if (lastChildrenId) {
|
|
57240
|
+
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
57241
|
+
this.index.moveToZIndex(item, zIndex);
|
|
57242
|
+
}
|
|
57243
|
+
item.isLockedGroup = false;
|
|
57244
|
+
}
|
|
57199
57245
|
applyRemoveOperation(op) {
|
|
57200
57246
|
const removedItems = [];
|
|
57201
57247
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -57224,6 +57270,21 @@ class Board {
|
|
|
57224
57270
|
removedItems.push(item2);
|
|
57225
57271
|
});
|
|
57226
57272
|
}
|
|
57273
|
+
applyRemoveGroupOperation(op) {
|
|
57274
|
+
const item = this.index.getById(op.item[0]);
|
|
57275
|
+
if (!item || !(item instanceof Group)) {
|
|
57276
|
+
return;
|
|
57277
|
+
}
|
|
57278
|
+
item.getChildren().forEach((item2) => {
|
|
57279
|
+
item2.parent = "Board";
|
|
57280
|
+
});
|
|
57281
|
+
const removedItems = [];
|
|
57282
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
57283
|
+
this.index.remove(item2);
|
|
57284
|
+
this.selection.remove(item2);
|
|
57285
|
+
removedItems.push(item2);
|
|
57286
|
+
});
|
|
57287
|
+
}
|
|
57227
57288
|
applyItemOperation(op) {
|
|
57228
57289
|
if ("item" in op) {
|
|
57229
57290
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -57298,20 +57359,21 @@ class Board {
|
|
|
57298
57359
|
this.handleNesting(newItem);
|
|
57299
57360
|
return newItem;
|
|
57300
57361
|
}
|
|
57301
|
-
addLockedGroup(
|
|
57362
|
+
addLockedGroup(items) {
|
|
57302
57363
|
const id = this.getNewItemId();
|
|
57364
|
+
const groupData = {
|
|
57365
|
+
itemType: "Group",
|
|
57366
|
+
children: items.map((i) => i.getId()),
|
|
57367
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
57368
|
+
isLockedGroup: true
|
|
57369
|
+
};
|
|
57303
57370
|
this.emit({
|
|
57304
57371
|
class: "Board",
|
|
57305
57372
|
method: "addLockedGroup",
|
|
57306
57373
|
item: id,
|
|
57307
|
-
data:
|
|
57374
|
+
data: groupData
|
|
57308
57375
|
});
|
|
57309
|
-
|
|
57310
|
-
if (!newItem) {
|
|
57311
|
-
throw new Error(`Add item. Item ${id} was not created.`);
|
|
57312
|
-
}
|
|
57313
|
-
this.handleNesting(newItem);
|
|
57314
|
-
return newItem;
|
|
57376
|
+
return this.items.getById(id);
|
|
57315
57377
|
}
|
|
57316
57378
|
remove(item, withConnectors = true) {
|
|
57317
57379
|
let connectors = [];
|
|
@@ -57339,11 +57401,12 @@ class Board {
|
|
|
57339
57401
|
const groupData = {
|
|
57340
57402
|
itemType: "Group",
|
|
57341
57403
|
children: items.map((i) => i.getId()),
|
|
57342
|
-
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1,
|
|
57404
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
57405
|
+
isLockedGroup: false
|
|
57343
57406
|
};
|
|
57344
57407
|
this.emit({
|
|
57345
57408
|
class: "Board",
|
|
57346
|
-
method: "
|
|
57409
|
+
method: "addGroup",
|
|
57347
57410
|
item: id,
|
|
57348
57411
|
data: groupData
|
|
57349
57412
|
});
|
|
@@ -57352,7 +57415,7 @@ class Board {
|
|
|
57352
57415
|
ungroup(group) {
|
|
57353
57416
|
this.emit({
|
|
57354
57417
|
class: "Board",
|
|
57355
|
-
method: "
|
|
57418
|
+
method: "removeGroup",
|
|
57356
57419
|
item: [group.getId()]
|
|
57357
57420
|
});
|
|
57358
57421
|
}
|
package/dist/esm/browser.js
CHANGED
|
@@ -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,
|
|
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) {
|
|
@@ -54504,12 +54533,17 @@ class Board {
|
|
|
54504
54533
|
return this.applyAddItems(op);
|
|
54505
54534
|
case "addLockedGroup":
|
|
54506
54535
|
return this.applyAddLockedGroupOperation(op);
|
|
54536
|
+
case "addGroup":
|
|
54537
|
+
return this.applyAddGroupOperation(op);
|
|
54507
54538
|
case "remove": {
|
|
54508
54539
|
return this.applyRemoveOperation(op);
|
|
54509
54540
|
}
|
|
54510
54541
|
case "removeLockedGroup": {
|
|
54511
54542
|
return this.applyRemoveLockedGroupOperation(op);
|
|
54512
54543
|
}
|
|
54544
|
+
case "removeGroup": {
|
|
54545
|
+
return this.applyRemoveGroupOperation(op);
|
|
54546
|
+
}
|
|
54513
54547
|
case "paste": {
|
|
54514
54548
|
return this.applyPasteOperation(op.itemsMap);
|
|
54515
54549
|
}
|
|
@@ -54547,11 +54581,23 @@ class Board {
|
|
|
54547
54581
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54548
54582
|
this.index.moveToZIndex(item, zIndex);
|
|
54549
54583
|
}
|
|
54584
|
+
item.isLockedGroup = true;
|
|
54550
54585
|
item.getChildren().forEach((item2) => {
|
|
54551
54586
|
item2.transformation.isLocked = true;
|
|
54552
54587
|
});
|
|
54553
54588
|
item.transformation.isLocked = true;
|
|
54554
54589
|
}
|
|
54590
|
+
applyAddGroupOperation(op) {
|
|
54591
|
+
const item = this.createItem(op.item, op.data);
|
|
54592
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
54593
|
+
this.index.insert(item);
|
|
54594
|
+
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
54595
|
+
if (lastChildrenId) {
|
|
54596
|
+
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54597
|
+
this.index.moveToZIndex(item, zIndex);
|
|
54598
|
+
}
|
|
54599
|
+
item.isLockedGroup = false;
|
|
54600
|
+
}
|
|
54555
54601
|
applyRemoveOperation(op) {
|
|
54556
54602
|
const removedItems = [];
|
|
54557
54603
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54580,6 +54626,21 @@ class Board {
|
|
|
54580
54626
|
removedItems.push(item2);
|
|
54581
54627
|
});
|
|
54582
54628
|
}
|
|
54629
|
+
applyRemoveGroupOperation(op) {
|
|
54630
|
+
const item = this.index.getById(op.item[0]);
|
|
54631
|
+
if (!item || !(item instanceof Group)) {
|
|
54632
|
+
return;
|
|
54633
|
+
}
|
|
54634
|
+
item.getChildren().forEach((item2) => {
|
|
54635
|
+
item2.parent = "Board";
|
|
54636
|
+
});
|
|
54637
|
+
const removedItems = [];
|
|
54638
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
54639
|
+
this.index.remove(item2);
|
|
54640
|
+
this.selection.remove(item2);
|
|
54641
|
+
removedItems.push(item2);
|
|
54642
|
+
});
|
|
54643
|
+
}
|
|
54583
54644
|
applyItemOperation(op) {
|
|
54584
54645
|
if ("item" in op) {
|
|
54585
54646
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54654,20 +54715,21 @@ class Board {
|
|
|
54654
54715
|
this.handleNesting(newItem);
|
|
54655
54716
|
return newItem;
|
|
54656
54717
|
}
|
|
54657
|
-
addLockedGroup(
|
|
54718
|
+
addLockedGroup(items) {
|
|
54658
54719
|
const id = this.getNewItemId();
|
|
54720
|
+
const groupData = {
|
|
54721
|
+
itemType: "Group",
|
|
54722
|
+
children: items.map((i) => i.getId()),
|
|
54723
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54724
|
+
isLockedGroup: true
|
|
54725
|
+
};
|
|
54659
54726
|
this.emit({
|
|
54660
54727
|
class: "Board",
|
|
54661
54728
|
method: "addLockedGroup",
|
|
54662
54729
|
item: id,
|
|
54663
|
-
data:
|
|
54730
|
+
data: groupData
|
|
54664
54731
|
});
|
|
54665
|
-
|
|
54666
|
-
if (!newItem) {
|
|
54667
|
-
throw new Error(`Add item. Item ${id} was not created.`);
|
|
54668
|
-
}
|
|
54669
|
-
this.handleNesting(newItem);
|
|
54670
|
-
return newItem;
|
|
54732
|
+
return this.items.getById(id);
|
|
54671
54733
|
}
|
|
54672
54734
|
remove(item, withConnectors = true) {
|
|
54673
54735
|
let connectors = [];
|
|
@@ -54695,11 +54757,12 @@ class Board {
|
|
|
54695
54757
|
const groupData = {
|
|
54696
54758
|
itemType: "Group",
|
|
54697
54759
|
children: items.map((i) => i.getId()),
|
|
54698
|
-
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1,
|
|
54760
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54761
|
+
isLockedGroup: false
|
|
54699
54762
|
};
|
|
54700
54763
|
this.emit({
|
|
54701
54764
|
class: "Board",
|
|
54702
|
-
method: "
|
|
54765
|
+
method: "addGroup",
|
|
54703
54766
|
item: id,
|
|
54704
54767
|
data: groupData
|
|
54705
54768
|
});
|
|
@@ -54708,7 +54771,7 @@ class Board {
|
|
|
54708
54771
|
ungroup(group) {
|
|
54709
54772
|
this.emit({
|
|
54710
54773
|
class: "Board",
|
|
54711
|
-
method: "
|
|
54774
|
+
method: "removeGroup",
|
|
54712
54775
|
item: [group.getId()]
|
|
54713
54776
|
});
|
|
54714
54777
|
}
|
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,
|
|
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) {
|
|
@@ -54497,12 +54526,17 @@ class Board {
|
|
|
54497
54526
|
return this.applyAddItems(op);
|
|
54498
54527
|
case "addLockedGroup":
|
|
54499
54528
|
return this.applyAddLockedGroupOperation(op);
|
|
54529
|
+
case "addGroup":
|
|
54530
|
+
return this.applyAddGroupOperation(op);
|
|
54500
54531
|
case "remove": {
|
|
54501
54532
|
return this.applyRemoveOperation(op);
|
|
54502
54533
|
}
|
|
54503
54534
|
case "removeLockedGroup": {
|
|
54504
54535
|
return this.applyRemoveLockedGroupOperation(op);
|
|
54505
54536
|
}
|
|
54537
|
+
case "removeGroup": {
|
|
54538
|
+
return this.applyRemoveGroupOperation(op);
|
|
54539
|
+
}
|
|
54506
54540
|
case "paste": {
|
|
54507
54541
|
return this.applyPasteOperation(op.itemsMap);
|
|
54508
54542
|
}
|
|
@@ -54540,11 +54574,23 @@ class Board {
|
|
|
54540
54574
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54541
54575
|
this.index.moveToZIndex(item, zIndex);
|
|
54542
54576
|
}
|
|
54577
|
+
item.isLockedGroup = true;
|
|
54543
54578
|
item.getChildren().forEach((item2) => {
|
|
54544
54579
|
item2.transformation.isLocked = true;
|
|
54545
54580
|
});
|
|
54546
54581
|
item.transformation.isLocked = true;
|
|
54547
54582
|
}
|
|
54583
|
+
applyAddGroupOperation(op) {
|
|
54584
|
+
const item = this.createItem(op.item, op.data);
|
|
54585
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
54586
|
+
this.index.insert(item);
|
|
54587
|
+
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
54588
|
+
if (lastChildrenId) {
|
|
54589
|
+
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
54590
|
+
this.index.moveToZIndex(item, zIndex);
|
|
54591
|
+
}
|
|
54592
|
+
item.isLockedGroup = false;
|
|
54593
|
+
}
|
|
54548
54594
|
applyRemoveOperation(op) {
|
|
54549
54595
|
const removedItems = [];
|
|
54550
54596
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54573,6 +54619,21 @@ class Board {
|
|
|
54573
54619
|
removedItems.push(item2);
|
|
54574
54620
|
});
|
|
54575
54621
|
}
|
|
54622
|
+
applyRemoveGroupOperation(op) {
|
|
54623
|
+
const item = this.index.getById(op.item[0]);
|
|
54624
|
+
if (!item || !(item instanceof Group)) {
|
|
54625
|
+
return;
|
|
54626
|
+
}
|
|
54627
|
+
item.getChildren().forEach((item2) => {
|
|
54628
|
+
item2.parent = "Board";
|
|
54629
|
+
});
|
|
54630
|
+
const removedItems = [];
|
|
54631
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
54632
|
+
this.index.remove(item2);
|
|
54633
|
+
this.selection.remove(item2);
|
|
54634
|
+
removedItems.push(item2);
|
|
54635
|
+
});
|
|
54636
|
+
}
|
|
54576
54637
|
applyItemOperation(op) {
|
|
54577
54638
|
if ("item" in op) {
|
|
54578
54639
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -54647,20 +54708,21 @@ class Board {
|
|
|
54647
54708
|
this.handleNesting(newItem);
|
|
54648
54709
|
return newItem;
|
|
54649
54710
|
}
|
|
54650
|
-
addLockedGroup(
|
|
54711
|
+
addLockedGroup(items) {
|
|
54651
54712
|
const id = this.getNewItemId();
|
|
54713
|
+
const groupData = {
|
|
54714
|
+
itemType: "Group",
|
|
54715
|
+
children: items.map((i) => i.getId()),
|
|
54716
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54717
|
+
isLockedGroup: true
|
|
54718
|
+
};
|
|
54652
54719
|
this.emit({
|
|
54653
54720
|
class: "Board",
|
|
54654
54721
|
method: "addLockedGroup",
|
|
54655
54722
|
item: id,
|
|
54656
|
-
data:
|
|
54723
|
+
data: groupData
|
|
54657
54724
|
});
|
|
54658
|
-
|
|
54659
|
-
if (!newItem) {
|
|
54660
|
-
throw new Error(`Add item. Item ${id} was not created.`);
|
|
54661
|
-
}
|
|
54662
|
-
this.handleNesting(newItem);
|
|
54663
|
-
return newItem;
|
|
54725
|
+
return this.items.getById(id);
|
|
54664
54726
|
}
|
|
54665
54727
|
remove(item, withConnectors = true) {
|
|
54666
54728
|
let connectors = [];
|
|
@@ -54688,11 +54750,12 @@ class Board {
|
|
|
54688
54750
|
const groupData = {
|
|
54689
54751
|
itemType: "Group",
|
|
54690
54752
|
children: items.map((i) => i.getId()),
|
|
54691
|
-
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1,
|
|
54753
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
54754
|
+
isLockedGroup: false
|
|
54692
54755
|
};
|
|
54693
54756
|
this.emit({
|
|
54694
54757
|
class: "Board",
|
|
54695
|
-
method: "
|
|
54758
|
+
method: "addGroup",
|
|
54696
54759
|
item: id,
|
|
54697
54760
|
data: groupData
|
|
54698
54761
|
});
|
|
@@ -54701,7 +54764,7 @@ class Board {
|
|
|
54701
54764
|
ungroup(group) {
|
|
54702
54765
|
this.emit({
|
|
54703
54766
|
class: "Board",
|
|
54704
|
-
method: "
|
|
54767
|
+
method: "removeGroup",
|
|
54705
54768
|
item: [group.getId()]
|
|
54706
54769
|
});
|
|
54707
54770
|
}
|
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,
|
|
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) {
|
|
@@ -56965,12 +56994,17 @@ class Board {
|
|
|
56965
56994
|
return this.applyAddItems(op);
|
|
56966
56995
|
case "addLockedGroup":
|
|
56967
56996
|
return this.applyAddLockedGroupOperation(op);
|
|
56997
|
+
case "addGroup":
|
|
56998
|
+
return this.applyAddGroupOperation(op);
|
|
56968
56999
|
case "remove": {
|
|
56969
57000
|
return this.applyRemoveOperation(op);
|
|
56970
57001
|
}
|
|
56971
57002
|
case "removeLockedGroup": {
|
|
56972
57003
|
return this.applyRemoveLockedGroupOperation(op);
|
|
56973
57004
|
}
|
|
57005
|
+
case "removeGroup": {
|
|
57006
|
+
return this.applyRemoveGroupOperation(op);
|
|
57007
|
+
}
|
|
56974
57008
|
case "paste": {
|
|
56975
57009
|
return this.applyPasteOperation(op.itemsMap);
|
|
56976
57010
|
}
|
|
@@ -57008,11 +57042,23 @@ class Board {
|
|
|
57008
57042
|
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
57009
57043
|
this.index.moveToZIndex(item, zIndex);
|
|
57010
57044
|
}
|
|
57045
|
+
item.isLockedGroup = true;
|
|
57011
57046
|
item.getChildren().forEach((item2) => {
|
|
57012
57047
|
item2.transformation.isLocked = true;
|
|
57013
57048
|
});
|
|
57014
57049
|
item.transformation.isLocked = true;
|
|
57015
57050
|
}
|
|
57051
|
+
applyAddGroupOperation(op) {
|
|
57052
|
+
const item = this.createItem(op.item, op.data);
|
|
57053
|
+
const groupChildrenIds = item.getChildrenIds();
|
|
57054
|
+
this.index.insert(item);
|
|
57055
|
+
const lastChildrenId = this.index.getById(groupChildrenIds[groupChildrenIds.length - 1]);
|
|
57056
|
+
if (lastChildrenId) {
|
|
57057
|
+
const zIndex = this.index.getZIndex(lastChildrenId) + 1;
|
|
57058
|
+
this.index.moveToZIndex(item, zIndex);
|
|
57059
|
+
}
|
|
57060
|
+
item.isLockedGroup = false;
|
|
57061
|
+
}
|
|
57016
57062
|
applyRemoveOperation(op) {
|
|
57017
57063
|
const removedItems = [];
|
|
57018
57064
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -57041,6 +57087,21 @@ class Board {
|
|
|
57041
57087
|
removedItems.push(item2);
|
|
57042
57088
|
});
|
|
57043
57089
|
}
|
|
57090
|
+
applyRemoveGroupOperation(op) {
|
|
57091
|
+
const item = this.index.getById(op.item[0]);
|
|
57092
|
+
if (!item || !(item instanceof Group)) {
|
|
57093
|
+
return;
|
|
57094
|
+
}
|
|
57095
|
+
item.getChildren().forEach((item2) => {
|
|
57096
|
+
item2.parent = "Board";
|
|
57097
|
+
});
|
|
57098
|
+
const removedItems = [];
|
|
57099
|
+
this.findItemAndApply(op.item, (item2) => {
|
|
57100
|
+
this.index.remove(item2);
|
|
57101
|
+
this.selection.remove(item2);
|
|
57102
|
+
removedItems.push(item2);
|
|
57103
|
+
});
|
|
57104
|
+
}
|
|
57044
57105
|
applyItemOperation(op) {
|
|
57045
57106
|
if ("item" in op) {
|
|
57046
57107
|
this.findItemAndApply(op.item, (item) => {
|
|
@@ -57115,20 +57176,21 @@ class Board {
|
|
|
57115
57176
|
this.handleNesting(newItem);
|
|
57116
57177
|
return newItem;
|
|
57117
57178
|
}
|
|
57118
|
-
addLockedGroup(
|
|
57179
|
+
addLockedGroup(items) {
|
|
57119
57180
|
const id = this.getNewItemId();
|
|
57181
|
+
const groupData = {
|
|
57182
|
+
itemType: "Group",
|
|
57183
|
+
children: items.map((i) => i.getId()),
|
|
57184
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
57185
|
+
isLockedGroup: true
|
|
57186
|
+
};
|
|
57120
57187
|
this.emit({
|
|
57121
57188
|
class: "Board",
|
|
57122
57189
|
method: "addLockedGroup",
|
|
57123
57190
|
item: id,
|
|
57124
|
-
data:
|
|
57191
|
+
data: groupData
|
|
57125
57192
|
});
|
|
57126
|
-
|
|
57127
|
-
if (!newItem) {
|
|
57128
|
-
throw new Error(`Add item. Item ${id} was not created.`);
|
|
57129
|
-
}
|
|
57130
|
-
this.handleNesting(newItem);
|
|
57131
|
-
return newItem;
|
|
57193
|
+
return this.items.getById(id);
|
|
57132
57194
|
}
|
|
57133
57195
|
remove(item, withConnectors = true) {
|
|
57134
57196
|
let connectors = [];
|
|
@@ -57156,11 +57218,12 @@ class Board {
|
|
|
57156
57218
|
const groupData = {
|
|
57157
57219
|
itemType: "Group",
|
|
57158
57220
|
children: items.map((i) => i.getId()),
|
|
57159
|
-
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1,
|
|
57221
|
+
transformation: { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, rotate: 0, isLocked: false },
|
|
57222
|
+
isLockedGroup: false
|
|
57160
57223
|
};
|
|
57161
57224
|
this.emit({
|
|
57162
57225
|
class: "Board",
|
|
57163
|
-
method: "
|
|
57226
|
+
method: "addGroup",
|
|
57164
57227
|
item: id,
|
|
57165
57228
|
data: groupData
|
|
57166
57229
|
});
|
|
@@ -57169,7 +57232,7 @@ class Board {
|
|
|
57169
57232
|
ungroup(group) {
|
|
57170
57233
|
this.emit({
|
|
57171
57234
|
class: "Board",
|
|
57172
|
-
method: "
|
|
57235
|
+
method: "removeGroup",
|
|
57173
57236
|
item: [group.getId()]
|
|
57174
57237
|
});
|
|
57175
57238
|
}
|
package/dist/types/Board.d.ts
CHANGED
|
@@ -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(
|
|
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;
|