microboard-temp 0.4.34 → 0.4.36
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 +94 -66
- package/dist/cjs/index.js +94 -66
- package/dist/cjs/node.js +94 -66
- package/dist/esm/browser.js +94 -66
- package/dist/esm/index.js +94 -66
- package/dist/esm/node.js +94 -66
- package/dist/types/Items/BaseItem/BaseItem.d.ts +12 -0
- package/dist/types/Items/BaseItem/BaseItemOperation.d.ts +7 -0
- package/dist/types/Items/Frame/Frame.d.ts +1 -9
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -19649,6 +19649,8 @@ class BaseItem extends Mbr {
|
|
|
19649
19649
|
transformation;
|
|
19650
19650
|
linkTo;
|
|
19651
19651
|
parent = "Board";
|
|
19652
|
+
children = null;
|
|
19653
|
+
canBeNested = true;
|
|
19652
19654
|
transformationRenderBlock = undefined;
|
|
19653
19655
|
board;
|
|
19654
19656
|
id;
|
|
@@ -19680,6 +19682,87 @@ class BaseItem extends Mbr {
|
|
|
19680
19682
|
this.getRichText()?.setId(id);
|
|
19681
19683
|
return this;
|
|
19682
19684
|
}
|
|
19685
|
+
addChildItems(children) {
|
|
19686
|
+
if (!this.children) {
|
|
19687
|
+
return;
|
|
19688
|
+
}
|
|
19689
|
+
const childrenIds = children.map((child) => {
|
|
19690
|
+
child.parent = this.getId();
|
|
19691
|
+
return child.getId();
|
|
19692
|
+
});
|
|
19693
|
+
this.updateChildren([...this.children, ...childrenIds]);
|
|
19694
|
+
}
|
|
19695
|
+
removeChildItems(children) {
|
|
19696
|
+
if (!this.children) {
|
|
19697
|
+
return;
|
|
19698
|
+
}
|
|
19699
|
+
const newChildren = Array.isArray(children) ? children : [children];
|
|
19700
|
+
const childrenIds = newChildren.map((child) => {
|
|
19701
|
+
child.parent = "Board";
|
|
19702
|
+
return child.getId();
|
|
19703
|
+
});
|
|
19704
|
+
this.updateChildren(this.children.filter((child) => !childrenIds.includes(child)));
|
|
19705
|
+
}
|
|
19706
|
+
emitNesting(children) {
|
|
19707
|
+
const itemsToAdd = [];
|
|
19708
|
+
const itemsToRemove = [];
|
|
19709
|
+
children.forEach((child) => {
|
|
19710
|
+
if (this.handleNesting(child)) {
|
|
19711
|
+
itemsToAdd.push(child);
|
|
19712
|
+
} else {
|
|
19713
|
+
itemsToRemove.push(child);
|
|
19714
|
+
}
|
|
19715
|
+
});
|
|
19716
|
+
this.addChildItems(itemsToAdd);
|
|
19717
|
+
this.removeChildItems(itemsToRemove);
|
|
19718
|
+
}
|
|
19719
|
+
updateChildren(children) {
|
|
19720
|
+
this.emit({
|
|
19721
|
+
class: this.itemType,
|
|
19722
|
+
method: "updateChildren",
|
|
19723
|
+
item: [this.getId()],
|
|
19724
|
+
newData: { children },
|
|
19725
|
+
prevData: { children: this.children }
|
|
19726
|
+
});
|
|
19727
|
+
}
|
|
19728
|
+
handleNesting(item, options) {
|
|
19729
|
+
const isItem = "itemType" in item;
|
|
19730
|
+
const itemMbr = isItem ? item.getMbr() : item;
|
|
19731
|
+
if (item instanceof BaseItem && !item.canBeNested) {
|
|
19732
|
+
return false;
|
|
19733
|
+
}
|
|
19734
|
+
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
19735
|
+
return false;
|
|
19736
|
+
}
|
|
19737
|
+
const mbr = this.getMbr().copy();
|
|
19738
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
19739
|
+
if (mbr.isInside(itemMbr.getCenter())) {
|
|
19740
|
+
if (!options || !options.onlyForOut) {
|
|
19741
|
+
return true;
|
|
19742
|
+
}
|
|
19743
|
+
}
|
|
19744
|
+
}
|
|
19745
|
+
return false;
|
|
19746
|
+
}
|
|
19747
|
+
applyUpdateChildren(children) {
|
|
19748
|
+
if (!this.children) {
|
|
19749
|
+
return;
|
|
19750
|
+
}
|
|
19751
|
+
children.forEach((child) => {
|
|
19752
|
+
if (this.parent !== child && this.getId() !== child) {
|
|
19753
|
+
const foundItem = this.board.items.getById(child);
|
|
19754
|
+
if (!this.children.includes(child) && foundItem) {
|
|
19755
|
+
foundItem.parent = this.getId();
|
|
19756
|
+
}
|
|
19757
|
+
}
|
|
19758
|
+
});
|
|
19759
|
+
this.children = children;
|
|
19760
|
+
this.updateMbr();
|
|
19761
|
+
this.subject.publish(this);
|
|
19762
|
+
}
|
|
19763
|
+
updateMbr() {
|
|
19764
|
+
return;
|
|
19765
|
+
}
|
|
19683
19766
|
getLinkTo() {
|
|
19684
19767
|
return this.linkTo.link;
|
|
19685
19768
|
}
|
|
@@ -19729,6 +19812,12 @@ class BaseItem extends Mbr {
|
|
|
19729
19812
|
case "LinkTo":
|
|
19730
19813
|
this.linkTo.apply(op);
|
|
19731
19814
|
break;
|
|
19815
|
+
case this.itemType:
|
|
19816
|
+
op = op;
|
|
19817
|
+
switch (op.method) {
|
|
19818
|
+
case "updateChildren":
|
|
19819
|
+
this.applyUpdateChildren(op.newData.children);
|
|
19820
|
+
}
|
|
19732
19821
|
}
|
|
19733
19822
|
}
|
|
19734
19823
|
addOnRemoveCallback(cb) {
|
|
@@ -38352,6 +38441,7 @@ class Frame extends BaseItem {
|
|
|
38352
38441
|
linkTo;
|
|
38353
38442
|
text;
|
|
38354
38443
|
canChangeRatio = true;
|
|
38444
|
+
canBeNested = false;
|
|
38355
38445
|
newShape = null;
|
|
38356
38446
|
transformationRenderBlock = undefined;
|
|
38357
38447
|
constructor(board, getItemById, id = "", name = "", shapeType = defaultFrameData.shapeType, backgroundColor = defaultFrameData.backgroundColor, backgroundOpacity = defaultFrameData.backgroundOpacity, borderColor = defaultFrameData.borderColor, borderOpacity = defaultFrameData.borderOpacity, borderStyle = defaultFrameData.borderStyle, borderWidth = defaultFrameData.borderWidth) {
|
|
@@ -38390,42 +38480,6 @@ class Frame extends BaseItem {
|
|
|
38390
38480
|
this.board = board;
|
|
38391
38481
|
return this;
|
|
38392
38482
|
}
|
|
38393
|
-
emitAddChild(children) {
|
|
38394
|
-
const childrenIds = children.map((child) => {
|
|
38395
|
-
child.parent = this.getId();
|
|
38396
|
-
return child.getId();
|
|
38397
|
-
});
|
|
38398
|
-
this.addChild(childrenIds);
|
|
38399
|
-
}
|
|
38400
|
-
emitRemoveChild(children) {
|
|
38401
|
-
const newChildren = Array.isArray(children) ? children : [children];
|
|
38402
|
-
const childrenIds = newChildren.map((child) => {
|
|
38403
|
-
child.parent = "Board";
|
|
38404
|
-
return child.getId();
|
|
38405
|
-
});
|
|
38406
|
-
this.removeChild(childrenIds);
|
|
38407
|
-
}
|
|
38408
|
-
emitNesting(children) {
|
|
38409
|
-
const itemsToAdd = [];
|
|
38410
|
-
const itemsToRemove = [];
|
|
38411
|
-
children.forEach((child) => {
|
|
38412
|
-
if (this.handleNesting(child)) {
|
|
38413
|
-
itemsToAdd.push(child);
|
|
38414
|
-
} else {
|
|
38415
|
-
itemsToRemove.push(child);
|
|
38416
|
-
}
|
|
38417
|
-
});
|
|
38418
|
-
this.emitAddChild(itemsToAdd);
|
|
38419
|
-
this.emitRemoveChild(itemsToRemove);
|
|
38420
|
-
}
|
|
38421
|
-
addChild(childId) {
|
|
38422
|
-
this.emit({
|
|
38423
|
-
class: "Frame",
|
|
38424
|
-
method: "addChild",
|
|
38425
|
-
item: [this.getId()],
|
|
38426
|
-
childId
|
|
38427
|
-
});
|
|
38428
|
-
}
|
|
38429
38483
|
applyAddChild(childId, noWarn = false) {
|
|
38430
38484
|
const children = Array.isArray(childId) ? childId : [childId];
|
|
38431
38485
|
children.forEach((child) => {
|
|
@@ -38446,36 +38500,9 @@ class Frame extends BaseItem {
|
|
|
38446
38500
|
this.children = this.children.filter((currChild) => !childId.includes(currChild));
|
|
38447
38501
|
this.subject.publish(this);
|
|
38448
38502
|
}
|
|
38449
|
-
removeChild(childId) {
|
|
38450
|
-
this.emit({
|
|
38451
|
-
class: "Frame",
|
|
38452
|
-
method: "removeChild",
|
|
38453
|
-
item: [this.getId()],
|
|
38454
|
-
childId
|
|
38455
|
-
});
|
|
38456
|
-
}
|
|
38457
38503
|
getLinkTo() {
|
|
38458
38504
|
return this.linkTo.link;
|
|
38459
38505
|
}
|
|
38460
|
-
handleNesting(item, options) {
|
|
38461
|
-
const isItem = "itemType" in item;
|
|
38462
|
-
const itemMbr = isItem ? item.getMbr() : item;
|
|
38463
|
-
if (item instanceof Frame) {
|
|
38464
|
-
return false;
|
|
38465
|
-
}
|
|
38466
|
-
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
38467
|
-
return false;
|
|
38468
|
-
}
|
|
38469
|
-
const frameMbr = this.getMbr().copy();
|
|
38470
|
-
if (item.isEnclosedOrCrossedBy(frameMbr)) {
|
|
38471
|
-
if (frameMbr.isInside(itemMbr.getCenter())) {
|
|
38472
|
-
if (!options || !options.onlyForOut) {
|
|
38473
|
-
return true;
|
|
38474
|
-
}
|
|
38475
|
-
}
|
|
38476
|
-
}
|
|
38477
|
-
return false;
|
|
38478
|
-
}
|
|
38479
38506
|
initPath() {
|
|
38480
38507
|
this.path = Frames[this.shapeType].path.copy();
|
|
38481
38508
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
@@ -38649,6 +38676,7 @@ class Frame extends BaseItem {
|
|
|
38649
38676
|
this.path.setBorderOpacity(this.borderOpacity);
|
|
38650
38677
|
}
|
|
38651
38678
|
apply(op) {
|
|
38679
|
+
super.apply(op);
|
|
38652
38680
|
switch (op.class) {
|
|
38653
38681
|
case "Frame":
|
|
38654
38682
|
if (op.method === "setBackgroundColor") {
|
|
@@ -50429,7 +50457,7 @@ class BoardSelection {
|
|
|
50429
50457
|
if (isParentFrame && isRemoveChildFromFrame) {
|
|
50430
50458
|
parentFrame.emitRemoveChild([val.item]);
|
|
50431
50459
|
}
|
|
50432
|
-
val.nested.
|
|
50460
|
+
val.nested.addChildItems([val.item]);
|
|
50433
50461
|
} else if (val.item.parent !== "Board") {
|
|
50434
50462
|
if (isParentFrame) {
|
|
50435
50463
|
parentFrame.emitRemoveChild([val.item]);
|
|
@@ -52119,7 +52147,7 @@ class SpatialIndex {
|
|
|
52119
52147
|
remove(item) {
|
|
52120
52148
|
if (item instanceof Frame) {
|
|
52121
52149
|
const newItems = item.getChildrenIds().map((childId) => this.getById(childId)).filter((child) => child !== undefined);
|
|
52122
|
-
item.
|
|
52150
|
+
item.removeChildItems(newItems);
|
|
52123
52151
|
}
|
|
52124
52152
|
if (item.parent !== "Board") {
|
|
52125
52153
|
const parentFrame = this.items.getById(item.parent);
|
|
@@ -53198,7 +53226,7 @@ class Board {
|
|
|
53198
53226
|
}
|
|
53199
53227
|
});
|
|
53200
53228
|
framesMap.forEach((items2, frame) => {
|
|
53201
|
-
frame.
|
|
53229
|
+
frame.addChildItems(items2);
|
|
53202
53230
|
});
|
|
53203
53231
|
}
|
|
53204
53232
|
createItem(id, data) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -19649,6 +19649,8 @@ class BaseItem extends Mbr {
|
|
|
19649
19649
|
transformation;
|
|
19650
19650
|
linkTo;
|
|
19651
19651
|
parent = "Board";
|
|
19652
|
+
children = null;
|
|
19653
|
+
canBeNested = true;
|
|
19652
19654
|
transformationRenderBlock = undefined;
|
|
19653
19655
|
board;
|
|
19654
19656
|
id;
|
|
@@ -19680,6 +19682,87 @@ class BaseItem extends Mbr {
|
|
|
19680
19682
|
this.getRichText()?.setId(id);
|
|
19681
19683
|
return this;
|
|
19682
19684
|
}
|
|
19685
|
+
addChildItems(children) {
|
|
19686
|
+
if (!this.children) {
|
|
19687
|
+
return;
|
|
19688
|
+
}
|
|
19689
|
+
const childrenIds = children.map((child) => {
|
|
19690
|
+
child.parent = this.getId();
|
|
19691
|
+
return child.getId();
|
|
19692
|
+
});
|
|
19693
|
+
this.updateChildren([...this.children, ...childrenIds]);
|
|
19694
|
+
}
|
|
19695
|
+
removeChildItems(children) {
|
|
19696
|
+
if (!this.children) {
|
|
19697
|
+
return;
|
|
19698
|
+
}
|
|
19699
|
+
const newChildren = Array.isArray(children) ? children : [children];
|
|
19700
|
+
const childrenIds = newChildren.map((child) => {
|
|
19701
|
+
child.parent = "Board";
|
|
19702
|
+
return child.getId();
|
|
19703
|
+
});
|
|
19704
|
+
this.updateChildren(this.children.filter((child) => !childrenIds.includes(child)));
|
|
19705
|
+
}
|
|
19706
|
+
emitNesting(children) {
|
|
19707
|
+
const itemsToAdd = [];
|
|
19708
|
+
const itemsToRemove = [];
|
|
19709
|
+
children.forEach((child) => {
|
|
19710
|
+
if (this.handleNesting(child)) {
|
|
19711
|
+
itemsToAdd.push(child);
|
|
19712
|
+
} else {
|
|
19713
|
+
itemsToRemove.push(child);
|
|
19714
|
+
}
|
|
19715
|
+
});
|
|
19716
|
+
this.addChildItems(itemsToAdd);
|
|
19717
|
+
this.removeChildItems(itemsToRemove);
|
|
19718
|
+
}
|
|
19719
|
+
updateChildren(children) {
|
|
19720
|
+
this.emit({
|
|
19721
|
+
class: this.itemType,
|
|
19722
|
+
method: "updateChildren",
|
|
19723
|
+
item: [this.getId()],
|
|
19724
|
+
newData: { children },
|
|
19725
|
+
prevData: { children: this.children }
|
|
19726
|
+
});
|
|
19727
|
+
}
|
|
19728
|
+
handleNesting(item, options) {
|
|
19729
|
+
const isItem = "itemType" in item;
|
|
19730
|
+
const itemMbr = isItem ? item.getMbr() : item;
|
|
19731
|
+
if (item instanceof BaseItem && !item.canBeNested) {
|
|
19732
|
+
return false;
|
|
19733
|
+
}
|
|
19734
|
+
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
19735
|
+
return false;
|
|
19736
|
+
}
|
|
19737
|
+
const mbr = this.getMbr().copy();
|
|
19738
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
19739
|
+
if (mbr.isInside(itemMbr.getCenter())) {
|
|
19740
|
+
if (!options || !options.onlyForOut) {
|
|
19741
|
+
return true;
|
|
19742
|
+
}
|
|
19743
|
+
}
|
|
19744
|
+
}
|
|
19745
|
+
return false;
|
|
19746
|
+
}
|
|
19747
|
+
applyUpdateChildren(children) {
|
|
19748
|
+
if (!this.children) {
|
|
19749
|
+
return;
|
|
19750
|
+
}
|
|
19751
|
+
children.forEach((child) => {
|
|
19752
|
+
if (this.parent !== child && this.getId() !== child) {
|
|
19753
|
+
const foundItem = this.board.items.getById(child);
|
|
19754
|
+
if (!this.children.includes(child) && foundItem) {
|
|
19755
|
+
foundItem.parent = this.getId();
|
|
19756
|
+
}
|
|
19757
|
+
}
|
|
19758
|
+
});
|
|
19759
|
+
this.children = children;
|
|
19760
|
+
this.updateMbr();
|
|
19761
|
+
this.subject.publish(this);
|
|
19762
|
+
}
|
|
19763
|
+
updateMbr() {
|
|
19764
|
+
return;
|
|
19765
|
+
}
|
|
19683
19766
|
getLinkTo() {
|
|
19684
19767
|
return this.linkTo.link;
|
|
19685
19768
|
}
|
|
@@ -19729,6 +19812,12 @@ class BaseItem extends Mbr {
|
|
|
19729
19812
|
case "LinkTo":
|
|
19730
19813
|
this.linkTo.apply(op);
|
|
19731
19814
|
break;
|
|
19815
|
+
case this.itemType:
|
|
19816
|
+
op = op;
|
|
19817
|
+
switch (op.method) {
|
|
19818
|
+
case "updateChildren":
|
|
19819
|
+
this.applyUpdateChildren(op.newData.children);
|
|
19820
|
+
}
|
|
19732
19821
|
}
|
|
19733
19822
|
}
|
|
19734
19823
|
addOnRemoveCallback(cb) {
|
|
@@ -38352,6 +38441,7 @@ class Frame extends BaseItem {
|
|
|
38352
38441
|
linkTo;
|
|
38353
38442
|
text;
|
|
38354
38443
|
canChangeRatio = true;
|
|
38444
|
+
canBeNested = false;
|
|
38355
38445
|
newShape = null;
|
|
38356
38446
|
transformationRenderBlock = undefined;
|
|
38357
38447
|
constructor(board, getItemById, id = "", name = "", shapeType = defaultFrameData.shapeType, backgroundColor = defaultFrameData.backgroundColor, backgroundOpacity = defaultFrameData.backgroundOpacity, borderColor = defaultFrameData.borderColor, borderOpacity = defaultFrameData.borderOpacity, borderStyle = defaultFrameData.borderStyle, borderWidth = defaultFrameData.borderWidth) {
|
|
@@ -38390,42 +38480,6 @@ class Frame extends BaseItem {
|
|
|
38390
38480
|
this.board = board;
|
|
38391
38481
|
return this;
|
|
38392
38482
|
}
|
|
38393
|
-
emitAddChild(children) {
|
|
38394
|
-
const childrenIds = children.map((child) => {
|
|
38395
|
-
child.parent = this.getId();
|
|
38396
|
-
return child.getId();
|
|
38397
|
-
});
|
|
38398
|
-
this.addChild(childrenIds);
|
|
38399
|
-
}
|
|
38400
|
-
emitRemoveChild(children) {
|
|
38401
|
-
const newChildren = Array.isArray(children) ? children : [children];
|
|
38402
|
-
const childrenIds = newChildren.map((child) => {
|
|
38403
|
-
child.parent = "Board";
|
|
38404
|
-
return child.getId();
|
|
38405
|
-
});
|
|
38406
|
-
this.removeChild(childrenIds);
|
|
38407
|
-
}
|
|
38408
|
-
emitNesting(children) {
|
|
38409
|
-
const itemsToAdd = [];
|
|
38410
|
-
const itemsToRemove = [];
|
|
38411
|
-
children.forEach((child) => {
|
|
38412
|
-
if (this.handleNesting(child)) {
|
|
38413
|
-
itemsToAdd.push(child);
|
|
38414
|
-
} else {
|
|
38415
|
-
itemsToRemove.push(child);
|
|
38416
|
-
}
|
|
38417
|
-
});
|
|
38418
|
-
this.emitAddChild(itemsToAdd);
|
|
38419
|
-
this.emitRemoveChild(itemsToRemove);
|
|
38420
|
-
}
|
|
38421
|
-
addChild(childId) {
|
|
38422
|
-
this.emit({
|
|
38423
|
-
class: "Frame",
|
|
38424
|
-
method: "addChild",
|
|
38425
|
-
item: [this.getId()],
|
|
38426
|
-
childId
|
|
38427
|
-
});
|
|
38428
|
-
}
|
|
38429
38483
|
applyAddChild(childId, noWarn = false) {
|
|
38430
38484
|
const children = Array.isArray(childId) ? childId : [childId];
|
|
38431
38485
|
children.forEach((child) => {
|
|
@@ -38446,36 +38500,9 @@ class Frame extends BaseItem {
|
|
|
38446
38500
|
this.children = this.children.filter((currChild) => !childId.includes(currChild));
|
|
38447
38501
|
this.subject.publish(this);
|
|
38448
38502
|
}
|
|
38449
|
-
removeChild(childId) {
|
|
38450
|
-
this.emit({
|
|
38451
|
-
class: "Frame",
|
|
38452
|
-
method: "removeChild",
|
|
38453
|
-
item: [this.getId()],
|
|
38454
|
-
childId
|
|
38455
|
-
});
|
|
38456
|
-
}
|
|
38457
38503
|
getLinkTo() {
|
|
38458
38504
|
return this.linkTo.link;
|
|
38459
38505
|
}
|
|
38460
|
-
handleNesting(item, options) {
|
|
38461
|
-
const isItem = "itemType" in item;
|
|
38462
|
-
const itemMbr = isItem ? item.getMbr() : item;
|
|
38463
|
-
if (item instanceof Frame) {
|
|
38464
|
-
return false;
|
|
38465
|
-
}
|
|
38466
|
-
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
38467
|
-
return false;
|
|
38468
|
-
}
|
|
38469
|
-
const frameMbr = this.getMbr().copy();
|
|
38470
|
-
if (item.isEnclosedOrCrossedBy(frameMbr)) {
|
|
38471
|
-
if (frameMbr.isInside(itemMbr.getCenter())) {
|
|
38472
|
-
if (!options || !options.onlyForOut) {
|
|
38473
|
-
return true;
|
|
38474
|
-
}
|
|
38475
|
-
}
|
|
38476
|
-
}
|
|
38477
|
-
return false;
|
|
38478
|
-
}
|
|
38479
38506
|
initPath() {
|
|
38480
38507
|
this.path = Frames[this.shapeType].path.copy();
|
|
38481
38508
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
@@ -38649,6 +38676,7 @@ class Frame extends BaseItem {
|
|
|
38649
38676
|
this.path.setBorderOpacity(this.borderOpacity);
|
|
38650
38677
|
}
|
|
38651
38678
|
apply(op) {
|
|
38679
|
+
super.apply(op);
|
|
38652
38680
|
switch (op.class) {
|
|
38653
38681
|
case "Frame":
|
|
38654
38682
|
if (op.method === "setBackgroundColor") {
|
|
@@ -50429,7 +50457,7 @@ class BoardSelection {
|
|
|
50429
50457
|
if (isParentFrame && isRemoveChildFromFrame) {
|
|
50430
50458
|
parentFrame.emitRemoveChild([val.item]);
|
|
50431
50459
|
}
|
|
50432
|
-
val.nested.
|
|
50460
|
+
val.nested.addChildItems([val.item]);
|
|
50433
50461
|
} else if (val.item.parent !== "Board") {
|
|
50434
50462
|
if (isParentFrame) {
|
|
50435
50463
|
parentFrame.emitRemoveChild([val.item]);
|
|
@@ -52119,7 +52147,7 @@ class SpatialIndex {
|
|
|
52119
52147
|
remove(item) {
|
|
52120
52148
|
if (item instanceof Frame) {
|
|
52121
52149
|
const newItems = item.getChildrenIds().map((childId) => this.getById(childId)).filter((child) => child !== undefined);
|
|
52122
|
-
item.
|
|
52150
|
+
item.removeChildItems(newItems);
|
|
52123
52151
|
}
|
|
52124
52152
|
if (item.parent !== "Board") {
|
|
52125
52153
|
const parentFrame = this.items.getById(item.parent);
|
|
@@ -53198,7 +53226,7 @@ class Board {
|
|
|
53198
53226
|
}
|
|
53199
53227
|
});
|
|
53200
53228
|
framesMap.forEach((items2, frame) => {
|
|
53201
|
-
frame.
|
|
53229
|
+
frame.addChildItems(items2);
|
|
53202
53230
|
});
|
|
53203
53231
|
}
|
|
53204
53232
|
createItem(id, data) {
|
package/dist/cjs/node.js
CHANGED
|
@@ -22188,6 +22188,8 @@ class BaseItem extends Mbr {
|
|
|
22188
22188
|
transformation;
|
|
22189
22189
|
linkTo;
|
|
22190
22190
|
parent = "Board";
|
|
22191
|
+
children = null;
|
|
22192
|
+
canBeNested = true;
|
|
22191
22193
|
transformationRenderBlock = undefined;
|
|
22192
22194
|
board;
|
|
22193
22195
|
id;
|
|
@@ -22219,6 +22221,87 @@ class BaseItem extends Mbr {
|
|
|
22219
22221
|
this.getRichText()?.setId(id);
|
|
22220
22222
|
return this;
|
|
22221
22223
|
}
|
|
22224
|
+
addChildItems(children) {
|
|
22225
|
+
if (!this.children) {
|
|
22226
|
+
return;
|
|
22227
|
+
}
|
|
22228
|
+
const childrenIds = children.map((child) => {
|
|
22229
|
+
child.parent = this.getId();
|
|
22230
|
+
return child.getId();
|
|
22231
|
+
});
|
|
22232
|
+
this.updateChildren([...this.children, ...childrenIds]);
|
|
22233
|
+
}
|
|
22234
|
+
removeChildItems(children) {
|
|
22235
|
+
if (!this.children) {
|
|
22236
|
+
return;
|
|
22237
|
+
}
|
|
22238
|
+
const newChildren = Array.isArray(children) ? children : [children];
|
|
22239
|
+
const childrenIds = newChildren.map((child) => {
|
|
22240
|
+
child.parent = "Board";
|
|
22241
|
+
return child.getId();
|
|
22242
|
+
});
|
|
22243
|
+
this.updateChildren(this.children.filter((child) => !childrenIds.includes(child)));
|
|
22244
|
+
}
|
|
22245
|
+
emitNesting(children) {
|
|
22246
|
+
const itemsToAdd = [];
|
|
22247
|
+
const itemsToRemove = [];
|
|
22248
|
+
children.forEach((child) => {
|
|
22249
|
+
if (this.handleNesting(child)) {
|
|
22250
|
+
itemsToAdd.push(child);
|
|
22251
|
+
} else {
|
|
22252
|
+
itemsToRemove.push(child);
|
|
22253
|
+
}
|
|
22254
|
+
});
|
|
22255
|
+
this.addChildItems(itemsToAdd);
|
|
22256
|
+
this.removeChildItems(itemsToRemove);
|
|
22257
|
+
}
|
|
22258
|
+
updateChildren(children) {
|
|
22259
|
+
this.emit({
|
|
22260
|
+
class: this.itemType,
|
|
22261
|
+
method: "updateChildren",
|
|
22262
|
+
item: [this.getId()],
|
|
22263
|
+
newData: { children },
|
|
22264
|
+
prevData: { children: this.children }
|
|
22265
|
+
});
|
|
22266
|
+
}
|
|
22267
|
+
handleNesting(item, options) {
|
|
22268
|
+
const isItem = "itemType" in item;
|
|
22269
|
+
const itemMbr = isItem ? item.getMbr() : item;
|
|
22270
|
+
if (item instanceof BaseItem && !item.canBeNested) {
|
|
22271
|
+
return false;
|
|
22272
|
+
}
|
|
22273
|
+
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
22274
|
+
return false;
|
|
22275
|
+
}
|
|
22276
|
+
const mbr = this.getMbr().copy();
|
|
22277
|
+
if (item.isEnclosedOrCrossedBy(mbr)) {
|
|
22278
|
+
if (mbr.isInside(itemMbr.getCenter())) {
|
|
22279
|
+
if (!options || !options.onlyForOut) {
|
|
22280
|
+
return true;
|
|
22281
|
+
}
|
|
22282
|
+
}
|
|
22283
|
+
}
|
|
22284
|
+
return false;
|
|
22285
|
+
}
|
|
22286
|
+
applyUpdateChildren(children) {
|
|
22287
|
+
if (!this.children) {
|
|
22288
|
+
return;
|
|
22289
|
+
}
|
|
22290
|
+
children.forEach((child) => {
|
|
22291
|
+
if (this.parent !== child && this.getId() !== child) {
|
|
22292
|
+
const foundItem = this.board.items.getById(child);
|
|
22293
|
+
if (!this.children.includes(child) && foundItem) {
|
|
22294
|
+
foundItem.parent = this.getId();
|
|
22295
|
+
}
|
|
22296
|
+
}
|
|
22297
|
+
});
|
|
22298
|
+
this.children = children;
|
|
22299
|
+
this.updateMbr();
|
|
22300
|
+
this.subject.publish(this);
|
|
22301
|
+
}
|
|
22302
|
+
updateMbr() {
|
|
22303
|
+
return;
|
|
22304
|
+
}
|
|
22222
22305
|
getLinkTo() {
|
|
22223
22306
|
return this.linkTo.link;
|
|
22224
22307
|
}
|
|
@@ -22268,6 +22351,12 @@ class BaseItem extends Mbr {
|
|
|
22268
22351
|
case "LinkTo":
|
|
22269
22352
|
this.linkTo.apply(op);
|
|
22270
22353
|
break;
|
|
22354
|
+
case this.itemType:
|
|
22355
|
+
op = op;
|
|
22356
|
+
switch (op.method) {
|
|
22357
|
+
case "updateChildren":
|
|
22358
|
+
this.applyUpdateChildren(op.newData.children);
|
|
22359
|
+
}
|
|
22271
22360
|
}
|
|
22272
22361
|
}
|
|
22273
22362
|
addOnRemoveCallback(cb) {
|
|
@@ -40892,6 +40981,7 @@ class Frame extends BaseItem {
|
|
|
40892
40981
|
linkTo;
|
|
40893
40982
|
text;
|
|
40894
40983
|
canChangeRatio = true;
|
|
40984
|
+
canBeNested = false;
|
|
40895
40985
|
newShape = null;
|
|
40896
40986
|
transformationRenderBlock = undefined;
|
|
40897
40987
|
constructor(board, getItemById, id = "", name = "", shapeType = defaultFrameData.shapeType, backgroundColor = defaultFrameData.backgroundColor, backgroundOpacity = defaultFrameData.backgroundOpacity, borderColor = defaultFrameData.borderColor, borderOpacity = defaultFrameData.borderOpacity, borderStyle = defaultFrameData.borderStyle, borderWidth = defaultFrameData.borderWidth) {
|
|
@@ -40930,42 +41020,6 @@ class Frame extends BaseItem {
|
|
|
40930
41020
|
this.board = board;
|
|
40931
41021
|
return this;
|
|
40932
41022
|
}
|
|
40933
|
-
emitAddChild(children) {
|
|
40934
|
-
const childrenIds = children.map((child) => {
|
|
40935
|
-
child.parent = this.getId();
|
|
40936
|
-
return child.getId();
|
|
40937
|
-
});
|
|
40938
|
-
this.addChild(childrenIds);
|
|
40939
|
-
}
|
|
40940
|
-
emitRemoveChild(children) {
|
|
40941
|
-
const newChildren = Array.isArray(children) ? children : [children];
|
|
40942
|
-
const childrenIds = newChildren.map((child) => {
|
|
40943
|
-
child.parent = "Board";
|
|
40944
|
-
return child.getId();
|
|
40945
|
-
});
|
|
40946
|
-
this.removeChild(childrenIds);
|
|
40947
|
-
}
|
|
40948
|
-
emitNesting(children) {
|
|
40949
|
-
const itemsToAdd = [];
|
|
40950
|
-
const itemsToRemove = [];
|
|
40951
|
-
children.forEach((child) => {
|
|
40952
|
-
if (this.handleNesting(child)) {
|
|
40953
|
-
itemsToAdd.push(child);
|
|
40954
|
-
} else {
|
|
40955
|
-
itemsToRemove.push(child);
|
|
40956
|
-
}
|
|
40957
|
-
});
|
|
40958
|
-
this.emitAddChild(itemsToAdd);
|
|
40959
|
-
this.emitRemoveChild(itemsToRemove);
|
|
40960
|
-
}
|
|
40961
|
-
addChild(childId) {
|
|
40962
|
-
this.emit({
|
|
40963
|
-
class: "Frame",
|
|
40964
|
-
method: "addChild",
|
|
40965
|
-
item: [this.getId()],
|
|
40966
|
-
childId
|
|
40967
|
-
});
|
|
40968
|
-
}
|
|
40969
41023
|
applyAddChild(childId, noWarn = false) {
|
|
40970
41024
|
const children = Array.isArray(childId) ? childId : [childId];
|
|
40971
41025
|
children.forEach((child) => {
|
|
@@ -40986,36 +41040,9 @@ class Frame extends BaseItem {
|
|
|
40986
41040
|
this.children = this.children.filter((currChild) => !childId.includes(currChild));
|
|
40987
41041
|
this.subject.publish(this);
|
|
40988
41042
|
}
|
|
40989
|
-
removeChild(childId) {
|
|
40990
|
-
this.emit({
|
|
40991
|
-
class: "Frame",
|
|
40992
|
-
method: "removeChild",
|
|
40993
|
-
item: [this.getId()],
|
|
40994
|
-
childId
|
|
40995
|
-
});
|
|
40996
|
-
}
|
|
40997
41043
|
getLinkTo() {
|
|
40998
41044
|
return this.linkTo.link;
|
|
40999
41045
|
}
|
|
41000
|
-
handleNesting(item, options) {
|
|
41001
|
-
const isItem = "itemType" in item;
|
|
41002
|
-
const itemMbr = isItem ? item.getMbr() : item;
|
|
41003
|
-
if (item instanceof Frame) {
|
|
41004
|
-
return false;
|
|
41005
|
-
}
|
|
41006
|
-
if (options?.cancelIfChild && isItem && item.parent !== "Board") {
|
|
41007
|
-
return false;
|
|
41008
|
-
}
|
|
41009
|
-
const frameMbr = this.getMbr().copy();
|
|
41010
|
-
if (item.isEnclosedOrCrossedBy(frameMbr)) {
|
|
41011
|
-
if (frameMbr.isInside(itemMbr.getCenter())) {
|
|
41012
|
-
if (!options || !options.onlyForOut) {
|
|
41013
|
-
return true;
|
|
41014
|
-
}
|
|
41015
|
-
}
|
|
41016
|
-
}
|
|
41017
|
-
return false;
|
|
41018
|
-
}
|
|
41019
41046
|
initPath() {
|
|
41020
41047
|
this.path = Frames[this.shapeType].path.copy();
|
|
41021
41048
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
@@ -41189,6 +41216,7 @@ class Frame extends BaseItem {
|
|
|
41189
41216
|
this.path.setBorderOpacity(this.borderOpacity);
|
|
41190
41217
|
}
|
|
41191
41218
|
apply(op) {
|
|
41219
|
+
super.apply(op);
|
|
41192
41220
|
switch (op.class) {
|
|
41193
41221
|
case "Frame":
|
|
41194
41222
|
if (op.method === "setBackgroundColor") {
|
|
@@ -52969,7 +52997,7 @@ class BoardSelection {
|
|
|
52969
52997
|
if (isParentFrame && isRemoveChildFromFrame) {
|
|
52970
52998
|
parentFrame.emitRemoveChild([val.item]);
|
|
52971
52999
|
}
|
|
52972
|
-
val.nested.
|
|
53000
|
+
val.nested.addChildItems([val.item]);
|
|
52973
53001
|
} else if (val.item.parent !== "Board") {
|
|
52974
53002
|
if (isParentFrame) {
|
|
52975
53003
|
parentFrame.emitRemoveChild([val.item]);
|
|
@@ -54592,7 +54620,7 @@ class SpatialIndex {
|
|
|
54592
54620
|
remove(item) {
|
|
54593
54621
|
if (item instanceof Frame) {
|
|
54594
54622
|
const newItems = item.getChildrenIds().map((childId) => this.getById(childId)).filter((child) => child !== undefined);
|
|
54595
|
-
item.
|
|
54623
|
+
item.removeChildItems(newItems);
|
|
54596
54624
|
}
|
|
54597
54625
|
if (item.parent !== "Board") {
|
|
54598
54626
|
const parentFrame = this.items.getById(item.parent);
|
|
@@ -55671,7 +55699,7 @@ class Board {
|
|
|
55671
55699
|
}
|
|
55672
55700
|
});
|
|
55673
55701
|
framesMap.forEach((items2, frame) => {
|
|
55674
|
-
frame.
|
|
55702
|
+
frame.addChildItems(items2);
|
|
55675
55703
|
});
|
|
55676
55704
|
}
|
|
55677
55705
|
createItem(id, data) {
|