microboard-temp 0.4.37 → 0.4.38
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 +137 -202
- package/dist/cjs/index.js +137 -202
- package/dist/cjs/node.js +137 -202
- package/dist/esm/browser.js +137 -202
- package/dist/esm/index.js +137 -202
- package/dist/esm/node.js +137 -202
- package/dist/types/Items/BaseItem/BaseItem.d.ts +3 -0
- package/dist/types/SpatialIndex/SpacialIndex.d.ts +14 -18
- package/dist/types/Tools/NestingHighlighter/NestingHighlighter.d.ts +4 -3
- package/package.json +1 -1
package/dist/cjs/node.js
CHANGED
|
@@ -22191,6 +22191,7 @@ class BaseItem extends Mbr {
|
|
|
22191
22191
|
children = null;
|
|
22192
22192
|
canBeNested = true;
|
|
22193
22193
|
transformationRenderBlock = undefined;
|
|
22194
|
+
childItems = null;
|
|
22194
22195
|
board;
|
|
22195
22196
|
id;
|
|
22196
22197
|
subject = new Subject;
|
|
@@ -22221,6 +22222,9 @@ class BaseItem extends Mbr {
|
|
|
22221
22222
|
this.getRichText()?.setId(id);
|
|
22222
22223
|
return this;
|
|
22223
22224
|
}
|
|
22225
|
+
getChildrenIds() {
|
|
22226
|
+
return this.children;
|
|
22227
|
+
}
|
|
22224
22228
|
addChildItems(children) {
|
|
22225
22229
|
if (!this.children) {
|
|
22226
22230
|
return;
|
|
@@ -22287,15 +22291,20 @@ class BaseItem extends Mbr {
|
|
|
22287
22291
|
if (!this.children) {
|
|
22288
22292
|
return;
|
|
22289
22293
|
}
|
|
22290
|
-
|
|
22291
|
-
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
+
const updatedChildItems = [];
|
|
22295
|
+
children.forEach((childId) => {
|
|
22296
|
+
const foundItem = this.board.items.getById(childId);
|
|
22297
|
+
if (foundItem) {
|
|
22298
|
+
updatedChildItems.push(foundItem);
|
|
22299
|
+
}
|
|
22300
|
+
if (this.parent !== childId && this.getId() !== childId) {
|
|
22301
|
+
if (!this.children.includes(childId) && foundItem) {
|
|
22294
22302
|
foundItem.parent = this.getId();
|
|
22295
22303
|
}
|
|
22296
22304
|
}
|
|
22297
22305
|
});
|
|
22298
22306
|
this.children = children;
|
|
22307
|
+
this.childItems = updatedChildItems;
|
|
22299
22308
|
this.updateMbr();
|
|
22300
22309
|
this.subject.publish(this);
|
|
22301
22310
|
}
|
|
@@ -22371,7 +22380,13 @@ class BaseItem extends Mbr {
|
|
|
22371
22380
|
getPath() {
|
|
22372
22381
|
return new Path(this.getMbr().getLines());
|
|
22373
22382
|
}
|
|
22374
|
-
render(context) {
|
|
22383
|
+
render(context) {
|
|
22384
|
+
if (this.childItems) {
|
|
22385
|
+
this.childItems.forEach((child) => {
|
|
22386
|
+
child.render(context);
|
|
22387
|
+
});
|
|
22388
|
+
}
|
|
22389
|
+
}
|
|
22375
22390
|
renderHTML(documentFactory) {
|
|
22376
22391
|
return documentFactory.createElement("div");
|
|
22377
22392
|
}
|
|
@@ -41401,8 +41416,10 @@ class Frame extends BaseItem {
|
|
|
41401
41416
|
if (this.transformationRenderBlock) {
|
|
41402
41417
|
return;
|
|
41403
41418
|
}
|
|
41404
|
-
this.
|
|
41405
|
-
|
|
41419
|
+
this.renderPath(context);
|
|
41420
|
+
super.render(context);
|
|
41421
|
+
this.renderBorders(context);
|
|
41422
|
+
this.renderName(context);
|
|
41406
41423
|
}
|
|
41407
41424
|
renderName(context) {
|
|
41408
41425
|
if (this.transformationRenderBlock) {
|
|
@@ -44518,8 +44535,8 @@ class NestingHighlighter extends Tool {
|
|
|
44518
44535
|
listAll() {
|
|
44519
44536
|
return this.toHighlight;
|
|
44520
44537
|
}
|
|
44521
|
-
add(
|
|
44522
|
-
const existing = this.toHighlight.find((group) => group.
|
|
44538
|
+
add(groupItem, children) {
|
|
44539
|
+
const existing = this.toHighlight.find((group) => group.groupItem === groupItem);
|
|
44523
44540
|
const array = Array.isArray(children) ? children : [children];
|
|
44524
44541
|
if (existing) {
|
|
44525
44542
|
array.forEach((child) => {
|
|
@@ -44528,7 +44545,7 @@ class NestingHighlighter extends Tool {
|
|
|
44528
44545
|
}
|
|
44529
44546
|
});
|
|
44530
44547
|
} else {
|
|
44531
|
-
this.toHighlight.push({
|
|
44548
|
+
this.toHighlight.push({ groupItem, children: array });
|
|
44532
44549
|
}
|
|
44533
44550
|
}
|
|
44534
44551
|
addSingleItem(item) {
|
|
@@ -44543,8 +44560,8 @@ class NestingHighlighter extends Tool {
|
|
|
44543
44560
|
render(context) {
|
|
44544
44561
|
if (this.toHighlight.length > 0) {
|
|
44545
44562
|
this.toHighlight.forEach((group) => {
|
|
44546
|
-
if (group.
|
|
44547
|
-
const frameRect = group.
|
|
44563
|
+
if (group.groupItem) {
|
|
44564
|
+
const frameRect = group.groupItem.getMbr();
|
|
44548
44565
|
frameRect.borderColor = FRAME_HIGHLIGHTER_BORDER_COLOR;
|
|
44549
44566
|
frameRect.strokeWidth = 0.3;
|
|
44550
44567
|
frameRect.render(context);
|
|
@@ -44639,7 +44656,7 @@ class AddFrame extends BoardTool {
|
|
|
44639
44656
|
return true;
|
|
44640
44657
|
}
|
|
44641
44658
|
addNextTo() {
|
|
44642
|
-
const framesInView = this.board.items.
|
|
44659
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame);
|
|
44643
44660
|
if (framesInView.length === 0) {
|
|
44644
44661
|
if (this.shape === "Custom") {
|
|
44645
44662
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -44651,7 +44668,7 @@ class AddFrame extends BoardTool {
|
|
|
44651
44668
|
}
|
|
44652
44669
|
this.transformToCenter();
|
|
44653
44670
|
} else {
|
|
44654
|
-
const frames = this.board.items.
|
|
44671
|
+
const frames = this.board.items.listAll().filter((frame2) => frame2 instanceof Frame && frame2 !== this.frame);
|
|
44655
44672
|
let nextTo = framesInView.reduce((rightest, frame2) => {
|
|
44656
44673
|
if (frame2.getMbr().right > rightest.getMbr().right) {
|
|
44657
44674
|
rightest = frame2;
|
|
@@ -45829,17 +45846,17 @@ function createCanvasDrawer(board) {
|
|
|
45829
45846
|
const realRight = realLeft + adjustedWidth;
|
|
45830
45847
|
const realBottom = realTop + adjustedHeight;
|
|
45831
45848
|
const containerMbr = new Mbr(realLeft, realTop, realRight, realBottom);
|
|
45832
|
-
const
|
|
45833
|
-
if (
|
|
45849
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(containerMbr.left, containerMbr.top, containerMbr.right, containerMbr.bottom);
|
|
45850
|
+
if (groups) {
|
|
45834
45851
|
drawnItemsMap?.forEach(({ mbr }) => {
|
|
45835
45852
|
mbr.transform(currMatrix);
|
|
45836
45853
|
});
|
|
45837
|
-
|
|
45854
|
+
groups.forEach((group) => {
|
|
45838
45855
|
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
45839
|
-
if (item
|
|
45856
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
45840
45857
|
return;
|
|
45841
45858
|
}
|
|
45842
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(
|
|
45859
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
45843
45860
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
45844
45861
|
removeHighlighted(key);
|
|
45845
45862
|
highlightedDivs.set(key, div);
|
|
@@ -47928,7 +47945,7 @@ class Tools extends ToolContext {
|
|
|
47928
47945
|
this.subject.publish(this);
|
|
47929
47946
|
}
|
|
47930
47947
|
sortFrames() {
|
|
47931
|
-
const frames = this.board.items.
|
|
47948
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame);
|
|
47932
47949
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
47933
47950
|
const mbr1 = fr1.getMbr();
|
|
47934
47951
|
const mbr2 = fr2.getMbr();
|
|
@@ -52015,9 +52032,9 @@ function updateFrameChildren({
|
|
|
52015
52032
|
board,
|
|
52016
52033
|
nestingHighlighter
|
|
52017
52034
|
}) {
|
|
52018
|
-
const
|
|
52035
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
52019
52036
|
board.selection.items.list().forEach((item) => {
|
|
52020
|
-
if (item
|
|
52037
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
52021
52038
|
const currMbr = item.getMbr();
|
|
52022
52039
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
52023
52040
|
itemsToCheck.forEach((currItem) => {
|
|
@@ -52028,9 +52045,9 @@ function updateFrameChildren({
|
|
|
52028
52045
|
}
|
|
52029
52046
|
});
|
|
52030
52047
|
} else {
|
|
52031
|
-
|
|
52032
|
-
if (
|
|
52033
|
-
nestingHighlighter.add(
|
|
52048
|
+
groups.forEach((group) => {
|
|
52049
|
+
if (group.handleNesting(item)) {
|
|
52050
|
+
nestingHighlighter.add(group, item);
|
|
52034
52051
|
} else {
|
|
52035
52052
|
nestingHighlighter.remove(item);
|
|
52036
52053
|
}
|
|
@@ -52549,9 +52566,7 @@ class BoardSelection {
|
|
|
52549
52566
|
}
|
|
52550
52567
|
addAll() {
|
|
52551
52568
|
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
52552
|
-
const frames = this.board.items.listFrames().filter((item) => !item.transformation.isLocked);
|
|
52553
52569
|
this.add(items);
|
|
52554
|
-
this.add(frames);
|
|
52555
52570
|
this.setContext("SelectByRect");
|
|
52556
52571
|
}
|
|
52557
52572
|
remove(value) {
|
|
@@ -52980,38 +52995,38 @@ class BoardSelection {
|
|
|
52980
52995
|
}, undefined);
|
|
52981
52996
|
if (selectedMbr) {
|
|
52982
52997
|
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
52983
|
-
const
|
|
52984
|
-
|
|
52998
|
+
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
52999
|
+
enclosedGroups.forEach((group) => {
|
|
52985
53000
|
selected.forEach((item) => {
|
|
52986
|
-
if (
|
|
52987
|
-
selectedMap[item.getId()].nested =
|
|
53001
|
+
if (group.handleNesting(item)) {
|
|
53002
|
+
selectedMap[item.getId()].nested = group;
|
|
52988
53003
|
}
|
|
52989
53004
|
});
|
|
52990
53005
|
});
|
|
52991
53006
|
Object.values(selectedMap).forEach((val) => {
|
|
52992
|
-
const
|
|
52993
|
-
const
|
|
52994
|
-
const parentFrameId = isParentFrame ? parentFrame.getId() : null;
|
|
53007
|
+
const parentGroup = this.board.items.getById(val.item.parent);
|
|
53008
|
+
const parentGroupId = parentGroup?.getId();
|
|
52995
53009
|
if (val.nested) {
|
|
52996
|
-
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !==
|
|
52997
|
-
if (
|
|
52998
|
-
|
|
53010
|
+
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentGroupId);
|
|
53011
|
+
if (parentGroupId && isRemoveChildFromFrame) {
|
|
53012
|
+
parentGroup?.removeChildItems([val.item]);
|
|
52999
53013
|
}
|
|
53000
53014
|
val.nested.addChildItems([val.item]);
|
|
53001
53015
|
} else if (val.item.parent !== "Board") {
|
|
53002
|
-
if (
|
|
53003
|
-
|
|
53016
|
+
if (parentGroupId) {
|
|
53017
|
+
parentGroup?.removeChildItems([val.item]);
|
|
53004
53018
|
} else {
|
|
53005
53019
|
console.warn(`Didnt find frame with id ${val.item.parent}`);
|
|
53006
53020
|
}
|
|
53007
53021
|
}
|
|
53008
|
-
|
|
53009
|
-
|
|
53010
|
-
const
|
|
53011
|
-
const
|
|
53012
|
-
const
|
|
53022
|
+
const childrenIds = val.item.getChildrenIds();
|
|
53023
|
+
if (childrenIds && checkFrames) {
|
|
53024
|
+
const currGroup = val.item;
|
|
53025
|
+
const currMbr = currGroup.getMbr();
|
|
53026
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
53027
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
53013
53028
|
const uniqueItems = new Set;
|
|
53014
|
-
const toCheck = [...children, ...
|
|
53029
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
53015
53030
|
const id = item.getId();
|
|
53016
53031
|
if (uniqueItems.has(id)) {
|
|
53017
53032
|
return false;
|
|
@@ -53019,7 +53034,7 @@ class BoardSelection {
|
|
|
53019
53034
|
uniqueItems.add(id);
|
|
53020
53035
|
return true;
|
|
53021
53036
|
});
|
|
53022
|
-
|
|
53037
|
+
currGroup.emitNesting(toCheck);
|
|
53023
53038
|
}
|
|
53024
53039
|
});
|
|
53025
53040
|
}
|
|
@@ -54562,13 +54577,9 @@ class LayeredIndex {
|
|
|
54562
54577
|
class SpatialIndex {
|
|
54563
54578
|
subject = new Subject;
|
|
54564
54579
|
itemsArray = [];
|
|
54565
|
-
framesArray = [];
|
|
54566
54580
|
itemsIndex = new LayeredIndex((item) => {
|
|
54567
54581
|
return this.itemsArray.indexOf(item);
|
|
54568
54582
|
});
|
|
54569
|
-
framesIndex = new LayeredIndex((item) => {
|
|
54570
|
-
return this.framesArray.indexOf(item);
|
|
54571
|
-
});
|
|
54572
54583
|
Mbr = new Mbr;
|
|
54573
54584
|
items;
|
|
54574
54585
|
constructor(view, pointer) {
|
|
@@ -54576,23 +54587,14 @@ class SpatialIndex {
|
|
|
54576
54587
|
}
|
|
54577
54588
|
clear() {
|
|
54578
54589
|
this.itemsArray = [];
|
|
54579
|
-
this.framesArray = [];
|
|
54580
54590
|
this.itemsIndex = new LayeredIndex((item) => {
|
|
54581
54591
|
return this.itemsArray.indexOf(item);
|
|
54582
54592
|
});
|
|
54583
|
-
this.framesIndex = new LayeredIndex((item) => {
|
|
54584
|
-
return this.framesArray.indexOf(item);
|
|
54585
|
-
});
|
|
54586
54593
|
this.Mbr = new Mbr;
|
|
54587
54594
|
}
|
|
54588
54595
|
insert(item) {
|
|
54589
|
-
|
|
54590
|
-
|
|
54591
|
-
this.framesIndex.insert(item);
|
|
54592
|
-
} else {
|
|
54593
|
-
this.itemsArray.push(item);
|
|
54594
|
-
this.itemsIndex.insert(item);
|
|
54595
|
-
}
|
|
54596
|
+
this.itemsArray.push(item);
|
|
54597
|
+
this.itemsIndex.insert(item);
|
|
54596
54598
|
if (conf.isNode()) {
|
|
54597
54599
|
return;
|
|
54598
54600
|
}
|
|
@@ -54605,11 +54607,7 @@ class SpatialIndex {
|
|
|
54605
54607
|
this.subject.publish(this.items);
|
|
54606
54608
|
}
|
|
54607
54609
|
change = (item) => {
|
|
54608
|
-
|
|
54609
|
-
this.framesIndex.change(item);
|
|
54610
|
-
} else {
|
|
54611
|
-
this.itemsIndex.change(item);
|
|
54612
|
-
}
|
|
54610
|
+
this.itemsIndex.change(item);
|
|
54613
54611
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
54614
54612
|
this.Mbr = item.getMbr().copy();
|
|
54615
54613
|
} else {
|
|
@@ -54626,39 +54624,22 @@ class SpatialIndex {
|
|
|
54626
54624
|
const parentFrame = this.items.getById(item.parent);
|
|
54627
54625
|
parentFrame?.removeChildItems(item);
|
|
54628
54626
|
}
|
|
54629
|
-
|
|
54630
|
-
|
|
54631
|
-
this.framesIndex.remove(item);
|
|
54632
|
-
} else {
|
|
54633
|
-
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
54634
|
-
this.itemsIndex.remove(item);
|
|
54635
|
-
}
|
|
54627
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
54628
|
+
this.itemsIndex.remove(item);
|
|
54636
54629
|
this.Mbr = new Mbr;
|
|
54637
|
-
|
|
54638
|
-
allItems.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
54630
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
54639
54631
|
this.subject.publish(this.items);
|
|
54640
54632
|
}
|
|
54641
54633
|
copy() {
|
|
54642
|
-
|
|
54634
|
+
return this.itemsArray.map((item) => ({
|
|
54643
54635
|
...item.serialize(true),
|
|
54644
54636
|
id: item.getId()
|
|
54645
54637
|
}));
|
|
54646
|
-
const framesData = this.framesArray.map((item) => ({
|
|
54647
|
-
...item.serialize(),
|
|
54648
|
-
id: item.getId()
|
|
54649
|
-
}));
|
|
54650
|
-
return [...framesData, ...itemsData];
|
|
54651
54638
|
}
|
|
54652
54639
|
moveToZIndex(item, zIndex) {
|
|
54653
|
-
|
|
54654
|
-
|
|
54655
|
-
|
|
54656
|
-
this.framesArray.splice(zIndex, 0, item);
|
|
54657
|
-
} else {
|
|
54658
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
54659
|
-
this.itemsArray.splice(index2, 1);
|
|
54660
|
-
this.itemsArray.splice(zIndex, 0, item);
|
|
54661
|
-
}
|
|
54640
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
54641
|
+
this.itemsArray.splice(index2, 1);
|
|
54642
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
54662
54643
|
this.change(item);
|
|
54663
54644
|
this.subject.publish(this.items);
|
|
54664
54645
|
}
|
|
@@ -54672,17 +54653,10 @@ class SpatialIndex {
|
|
|
54672
54653
|
this.itemsArray.forEach(this.change.bind(this));
|
|
54673
54654
|
}
|
|
54674
54655
|
sendToBack(item, shouldPublish = true) {
|
|
54675
|
-
|
|
54676
|
-
|
|
54677
|
-
|
|
54678
|
-
|
|
54679
|
-
this.framesIndex.change(item);
|
|
54680
|
-
} else {
|
|
54681
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
54682
|
-
this.itemsArray.splice(index2, 1);
|
|
54683
|
-
this.itemsArray.unshift(item);
|
|
54684
|
-
this.itemsIndex.change(item);
|
|
54685
|
-
}
|
|
54656
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
54657
|
+
this.itemsArray.splice(index2, 1);
|
|
54658
|
+
this.itemsArray.unshift(item);
|
|
54659
|
+
this.itemsIndex.change(item);
|
|
54686
54660
|
if (shouldPublish) {
|
|
54687
54661
|
this.subject.publish(this.items);
|
|
54688
54662
|
}
|
|
@@ -54698,17 +54672,10 @@ class SpatialIndex {
|
|
|
54698
54672
|
this.itemsArray.forEach(this.change.bind(this));
|
|
54699
54673
|
}
|
|
54700
54674
|
bringToFront(item, shouldPublish = true) {
|
|
54701
|
-
|
|
54702
|
-
|
|
54703
|
-
|
|
54704
|
-
|
|
54705
|
-
this.framesIndex.change(item);
|
|
54706
|
-
} else {
|
|
54707
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
54708
|
-
this.itemsArray.splice(index2, 1);
|
|
54709
|
-
this.itemsArray.push(item);
|
|
54710
|
-
this.itemsIndex.change(item);
|
|
54711
|
-
}
|
|
54675
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
54676
|
+
this.itemsArray.splice(index2, 1);
|
|
54677
|
+
this.itemsArray.push(item);
|
|
54678
|
+
this.itemsIndex.change(item);
|
|
54712
54679
|
if (shouldPublish) {
|
|
54713
54680
|
this.subject.publish(this.items);
|
|
54714
54681
|
}
|
|
@@ -54747,37 +54714,24 @@ class SpatialIndex {
|
|
|
54747
54714
|
if (item) {
|
|
54748
54715
|
return item;
|
|
54749
54716
|
}
|
|
54750
|
-
const frame = this.framesArray.find((frame2) => frame2.getId() === id);
|
|
54751
|
-
return frame;
|
|
54752
54717
|
}
|
|
54753
54718
|
findById(id) {
|
|
54754
54719
|
return this.getById(id);
|
|
54755
54720
|
}
|
|
54756
54721
|
getEnclosed(left, top, right, bottom) {
|
|
54757
54722
|
const mbr = new Mbr(left, top, right, bottom);
|
|
54758
|
-
|
|
54759
|
-
const enclosedFrames = this.framesIndex.getEnclosed(mbr);
|
|
54760
|
-
return enclosedFrames.concat(enclosedItems);
|
|
54723
|
+
return this.itemsIndex.getEnclosed(mbr);
|
|
54761
54724
|
}
|
|
54762
54725
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
54763
54726
|
const mbr = new Mbr(left, top, right, bottom);
|
|
54764
|
-
|
|
54765
|
-
const enclosedOrCrossedFrames = this.framesIndex.getEnclosedOrCrossedBy(mbr);
|
|
54766
|
-
return enclosedOrCrossedFrames.concat(enclosedOrCrossedItems);
|
|
54727
|
+
return this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
54767
54728
|
}
|
|
54768
54729
|
getUnderPoint(point5, tolerace = 5) {
|
|
54769
|
-
|
|
54770
|
-
const framesUnderPoint = this.framesIndex.getUnderPoint(point5, tolerace);
|
|
54771
|
-
return [...framesUnderPoint, ...itemsUnderPoint];
|
|
54730
|
+
return this.itemsIndex.getUnderPoint(point5, tolerace);
|
|
54772
54731
|
}
|
|
54773
54732
|
getRectsEnclosedOrCrossed(left, top, right, bottom) {
|
|
54774
54733
|
const mbr = new Mbr(left, top, right, bottom);
|
|
54775
|
-
|
|
54776
|
-
const woFrames = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
54777
|
-
return [...woFrames, ...frames];
|
|
54778
|
-
}
|
|
54779
|
-
getFramesEnclosedOrCrossed(left, top, right, bottom) {
|
|
54780
|
-
return this.framesIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
54734
|
+
return this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
54781
54735
|
}
|
|
54782
54736
|
getItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
54783
54737
|
return this.itemsIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
@@ -54790,44 +54744,28 @@ class SpatialIndex {
|
|
|
54790
54744
|
}
|
|
54791
54745
|
getNearestTo(point5, maxItems, filter, maxDistance) {
|
|
54792
54746
|
const nearestItems = this.itemsIndex.getNearestTo(point5, maxItems, filter, maxDistance);
|
|
54793
|
-
|
|
54794
|
-
const combined = nearestItems.concat(nearestFrames);
|
|
54795
|
-
combined.sort((aa, bb) => {
|
|
54747
|
+
nearestItems.sort((aa, bb) => {
|
|
54796
54748
|
const distA = point5.getDistance(aa.getMbr().getCenter());
|
|
54797
54749
|
const distB = point5.getDistance(bb.getMbr().getCenter());
|
|
54798
54750
|
return distA - distB;
|
|
54799
54751
|
});
|
|
54800
|
-
return
|
|
54752
|
+
return nearestItems.slice(0, maxItems);
|
|
54801
54753
|
}
|
|
54802
54754
|
list() {
|
|
54803
54755
|
return this.itemsArray.concat();
|
|
54804
54756
|
}
|
|
54805
|
-
listFrames() {
|
|
54806
|
-
return this.framesArray.concat();
|
|
54807
|
-
}
|
|
54808
54757
|
getZIndex(item) {
|
|
54809
|
-
|
|
54810
|
-
return this.framesArray.indexOf(item);
|
|
54811
|
-
} else {
|
|
54812
|
-
return this.itemsArray.indexOf(item);
|
|
54813
|
-
}
|
|
54758
|
+
return this.itemsArray.indexOf(item);
|
|
54814
54759
|
}
|
|
54815
54760
|
getLastZIndex() {
|
|
54816
|
-
return this.itemsArray.length
|
|
54761
|
+
return this.itemsArray.length - 1;
|
|
54817
54762
|
}
|
|
54818
54763
|
getByZIndex(index2) {
|
|
54819
|
-
const totalItems = this.itemsArray.length + this.framesArray.length;
|
|
54820
54764
|
if (index2 < this.itemsArray.length) {
|
|
54821
54765
|
return this.itemsArray[index2];
|
|
54822
|
-
} else if (index2 < totalItems) {
|
|
54823
|
-
return this.framesArray[index2 - this.itemsArray.length];
|
|
54824
54766
|
} else {
|
|
54825
54767
|
const lastIndex = this.getLastZIndex();
|
|
54826
|
-
|
|
54827
|
-
return this.framesArray[lastIndex];
|
|
54828
|
-
} else {
|
|
54829
|
-
return this.itemsArray[lastIndex];
|
|
54830
|
-
}
|
|
54768
|
+
return this.itemsArray[lastIndex];
|
|
54831
54769
|
}
|
|
54832
54770
|
}
|
|
54833
54771
|
}
|
|
@@ -54850,7 +54788,10 @@ class Items {
|
|
|
54850
54788
|
return this.index.list();
|
|
54851
54789
|
}
|
|
54852
54790
|
listFrames() {
|
|
54853
|
-
return this.index.
|
|
54791
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
54792
|
+
}
|
|
54793
|
+
listGroupItems() {
|
|
54794
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
54854
54795
|
}
|
|
54855
54796
|
getById(id) {
|
|
54856
54797
|
return this.index.getById(id);
|
|
@@ -54864,8 +54805,8 @@ class Items {
|
|
|
54864
54805
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
54865
54806
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
54866
54807
|
}
|
|
54867
|
-
|
|
54868
|
-
return this.index.
|
|
54808
|
+
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
54809
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.getChildrenIds());
|
|
54869
54810
|
}
|
|
54870
54811
|
getUnderPoint(point5, tolerance = 5) {
|
|
54871
54812
|
return this.index.getUnderPoint(point5, tolerance);
|
|
@@ -54881,9 +54822,9 @@ class Items {
|
|
|
54881
54822
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
54882
54823
|
return this.index.getItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
54883
54824
|
}
|
|
54884
|
-
|
|
54825
|
+
getGroupItemsInView() {
|
|
54885
54826
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
54886
|
-
return this.
|
|
54827
|
+
return this.getGroupItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
54887
54828
|
}
|
|
54888
54829
|
getComments() {
|
|
54889
54830
|
return this.index.getComments();
|
|
@@ -54921,11 +54862,7 @@ class Items {
|
|
|
54921
54862
|
if (nearest) {
|
|
54922
54863
|
return [nearest];
|
|
54923
54864
|
}
|
|
54924
|
-
|
|
54925
|
-
if (frames.length === 0 && unmodifiedSize !== 16) {
|
|
54926
|
-
return this.getUnderPointer(16);
|
|
54927
|
-
}
|
|
54928
|
-
return frames;
|
|
54865
|
+
return [];
|
|
54929
54866
|
}
|
|
54930
54867
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
54931
54868
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
@@ -54976,41 +54913,39 @@ class Items {
|
|
|
54976
54913
|
});
|
|
54977
54914
|
}
|
|
54978
54915
|
render(context) {
|
|
54979
|
-
const
|
|
54980
|
-
|
|
54981
|
-
|
|
54982
|
-
|
|
54983
|
-
|
|
54984
|
-
frame.getChildrenIds().map((id) => this.getById(id)).forEach((child) => {
|
|
54985
|
-
if (child) {
|
|
54986
|
-
frameChildrenIds.push(child.getId());
|
|
54987
|
-
child.render(context);
|
|
54988
|
-
}
|
|
54989
|
-
});
|
|
54916
|
+
const items = this.getItemsInView();
|
|
54917
|
+
items.forEach((item) => {
|
|
54918
|
+
if (item.parent !== "Board") {
|
|
54919
|
+
item.render(context);
|
|
54920
|
+
}
|
|
54990
54921
|
});
|
|
54991
|
-
rest.filter((item) => !frameChildrenIds.includes(item.getId())).forEach((item) => item.render(context));
|
|
54992
|
-
frames.forEach((frame) => frame.renderBorders(context));
|
|
54993
|
-
frames.forEach((frame) => frame.renderName(context));
|
|
54994
54922
|
}
|
|
54995
54923
|
renderHTML(documentFactory) {
|
|
54996
|
-
const
|
|
54997
|
-
|
|
54998
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
54924
|
+
const items = this.getItemsInView();
|
|
54925
|
+
return this.getHTML(documentFactory, items);
|
|
54999
54926
|
}
|
|
55000
54927
|
getWholeHTML(documentFactory) {
|
|
55001
|
-
const
|
|
55002
|
-
|
|
55003
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
54928
|
+
const items = this.listAll();
|
|
54929
|
+
return this.getHTML(documentFactory, items);
|
|
55004
54930
|
}
|
|
55005
|
-
getHTML(documentFactory,
|
|
55006
|
-
const lowestCoordinates =
|
|
54931
|
+
getHTML(documentFactory, items) {
|
|
54932
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
55007
54933
|
left: Math.min(acc.left, mbr.left),
|
|
55008
54934
|
top: Math.min(acc.top, mbr.top)
|
|
55009
54935
|
}), { left: 0, top: 0 });
|
|
54936
|
+
const groups = [];
|
|
54937
|
+
const rest = [];
|
|
54938
|
+
items.forEach((item) => {
|
|
54939
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
54940
|
+
groups.push(item);
|
|
54941
|
+
} else {
|
|
54942
|
+
rest.push(item);
|
|
54943
|
+
}
|
|
54944
|
+
});
|
|
55010
54945
|
const childrenMap = new Map;
|
|
55011
|
-
const
|
|
55012
|
-
|
|
55013
|
-
const html4 =
|
|
54946
|
+
const GroupsHTML = groups.map((group) => {
|
|
54947
|
+
group.getChildrenIds().forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
54948
|
+
const html4 = group.renderHTML(documentFactory);
|
|
55014
54949
|
translateElementBy(html4, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
55015
54950
|
return html4;
|
|
55016
54951
|
});
|
|
@@ -55029,15 +54964,15 @@ class Items {
|
|
|
55029
54964
|
});
|
|
55030
54965
|
for (const item of restHTML) {
|
|
55031
54966
|
const parentFrameId = childrenMap.get(item.id);
|
|
55032
|
-
const
|
|
55033
|
-
if (
|
|
55034
|
-
positionRelatively(item,
|
|
55035
|
-
|
|
54967
|
+
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
54968
|
+
if (group) {
|
|
54969
|
+
positionRelatively(item, group);
|
|
54970
|
+
group.appendChild(item);
|
|
55036
54971
|
}
|
|
55037
54972
|
}
|
|
55038
54973
|
let result = "";
|
|
55039
|
-
for (const
|
|
55040
|
-
result +=
|
|
54974
|
+
for (const group of GroupsHTML) {
|
|
54975
|
+
result += group.outerHTML;
|
|
55041
54976
|
}
|
|
55042
54977
|
for (const item of restHTML) {
|
|
55043
54978
|
if (!childrenMap.get(item.id)) {
|
|
@@ -55682,24 +55617,24 @@ class Board {
|
|
|
55682
55617
|
}
|
|
55683
55618
|
handleNesting(items) {
|
|
55684
55619
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
55685
|
-
const
|
|
55620
|
+
const groupsMap = new Map;
|
|
55686
55621
|
arrayed.forEach((item) => {
|
|
55687
55622
|
const itemCenter = item.getMbr().getCenter();
|
|
55688
|
-
const
|
|
55689
|
-
if (!acc ||
|
|
55690
|
-
acc =
|
|
55623
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
55624
|
+
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
55625
|
+
acc = groupItem2;
|
|
55691
55626
|
}
|
|
55692
55627
|
return acc;
|
|
55693
55628
|
}, undefined);
|
|
55694
|
-
if (
|
|
55695
|
-
if (!
|
|
55696
|
-
|
|
55629
|
+
if (groupItem) {
|
|
55630
|
+
if (!groupsMap.has(groupItem)) {
|
|
55631
|
+
groupsMap.set(groupItem, []);
|
|
55697
55632
|
}
|
|
55698
|
-
|
|
55633
|
+
groupsMap.get(groupItem)?.push(item);
|
|
55699
55634
|
}
|
|
55700
55635
|
});
|
|
55701
|
-
|
|
55702
|
-
|
|
55636
|
+
groupsMap.forEach((items2, group) => {
|
|
55637
|
+
group.addChildItems(items2);
|
|
55703
55638
|
});
|
|
55704
55639
|
}
|
|
55705
55640
|
createItem(id, data) {
|
|
@@ -56412,7 +56347,7 @@ class Board {
|
|
|
56412
56347
|
return this.items.findById(item.getId()) !== undefined;
|
|
56413
56348
|
}
|
|
56414
56349
|
getMaxFrameSerial() {
|
|
56415
|
-
const existingNames = this.items.
|
|
56350
|
+
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
56416
56351
|
return existingNames.map((name) => name.match(/^Frame (\d+)$/)).filter((match) => match !== null).map((match) => parseInt(match[1], 10)).reduce((max2, num) => Math.max(max2, num), 0);
|
|
56417
56352
|
}
|
|
56418
56353
|
setInterfaceType(interfaceType) {
|