microboard-temp 0.4.37 → 0.4.39
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/esm/node.js
CHANGED
|
@@ -22029,6 +22029,7 @@ class BaseItem extends Mbr {
|
|
|
22029
22029
|
children = null;
|
|
22030
22030
|
canBeNested = true;
|
|
22031
22031
|
transformationRenderBlock = undefined;
|
|
22032
|
+
childItems = null;
|
|
22032
22033
|
board;
|
|
22033
22034
|
id;
|
|
22034
22035
|
subject = new Subject;
|
|
@@ -22059,6 +22060,9 @@ class BaseItem extends Mbr {
|
|
|
22059
22060
|
this.getRichText()?.setId(id);
|
|
22060
22061
|
return this;
|
|
22061
22062
|
}
|
|
22063
|
+
getChildrenIds() {
|
|
22064
|
+
return this.children;
|
|
22065
|
+
}
|
|
22062
22066
|
addChildItems(children) {
|
|
22063
22067
|
if (!this.children) {
|
|
22064
22068
|
return;
|
|
@@ -22125,15 +22129,20 @@ class BaseItem extends Mbr {
|
|
|
22125
22129
|
if (!this.children) {
|
|
22126
22130
|
return;
|
|
22127
22131
|
}
|
|
22128
|
-
|
|
22129
|
-
|
|
22130
|
-
|
|
22131
|
-
|
|
22132
|
+
const updatedChildItems = [];
|
|
22133
|
+
children.forEach((childId) => {
|
|
22134
|
+
const foundItem = this.board.items.getById(childId);
|
|
22135
|
+
if (foundItem) {
|
|
22136
|
+
updatedChildItems.push(foundItem);
|
|
22137
|
+
}
|
|
22138
|
+
if (this.parent !== childId && this.getId() !== childId) {
|
|
22139
|
+
if (!this.children.includes(childId) && foundItem) {
|
|
22132
22140
|
foundItem.parent = this.getId();
|
|
22133
22141
|
}
|
|
22134
22142
|
}
|
|
22135
22143
|
});
|
|
22136
22144
|
this.children = children;
|
|
22145
|
+
this.childItems = updatedChildItems;
|
|
22137
22146
|
this.updateMbr();
|
|
22138
22147
|
this.subject.publish(this);
|
|
22139
22148
|
}
|
|
@@ -22209,7 +22218,13 @@ class BaseItem extends Mbr {
|
|
|
22209
22218
|
getPath() {
|
|
22210
22219
|
return new Path(this.getMbr().getLines());
|
|
22211
22220
|
}
|
|
22212
|
-
render(context) {
|
|
22221
|
+
render(context) {
|
|
22222
|
+
if (this.childItems) {
|
|
22223
|
+
this.childItems.forEach((child) => {
|
|
22224
|
+
child.render(context);
|
|
22225
|
+
});
|
|
22226
|
+
}
|
|
22227
|
+
}
|
|
22213
22228
|
renderHTML(documentFactory) {
|
|
22214
22229
|
return documentFactory.createElement("div");
|
|
22215
22230
|
}
|
|
@@ -41239,8 +41254,10 @@ class Frame extends BaseItem {
|
|
|
41239
41254
|
if (this.transformationRenderBlock) {
|
|
41240
41255
|
return;
|
|
41241
41256
|
}
|
|
41242
|
-
this.
|
|
41243
|
-
|
|
41257
|
+
this.renderPath(context);
|
|
41258
|
+
super.render(context);
|
|
41259
|
+
this.renderBorders(context);
|
|
41260
|
+
this.renderName(context);
|
|
41244
41261
|
}
|
|
41245
41262
|
renderName(context) {
|
|
41246
41263
|
if (this.transformationRenderBlock) {
|
|
@@ -44356,8 +44373,8 @@ class NestingHighlighter extends Tool {
|
|
|
44356
44373
|
listAll() {
|
|
44357
44374
|
return this.toHighlight;
|
|
44358
44375
|
}
|
|
44359
|
-
add(
|
|
44360
|
-
const existing = this.toHighlight.find((group) => group.
|
|
44376
|
+
add(groupItem, children) {
|
|
44377
|
+
const existing = this.toHighlight.find((group) => group.groupItem === groupItem);
|
|
44361
44378
|
const array = Array.isArray(children) ? children : [children];
|
|
44362
44379
|
if (existing) {
|
|
44363
44380
|
array.forEach((child) => {
|
|
@@ -44366,7 +44383,7 @@ class NestingHighlighter extends Tool {
|
|
|
44366
44383
|
}
|
|
44367
44384
|
});
|
|
44368
44385
|
} else {
|
|
44369
|
-
this.toHighlight.push({
|
|
44386
|
+
this.toHighlight.push({ groupItem, children: array });
|
|
44370
44387
|
}
|
|
44371
44388
|
}
|
|
44372
44389
|
addSingleItem(item) {
|
|
@@ -44381,8 +44398,8 @@ class NestingHighlighter extends Tool {
|
|
|
44381
44398
|
render(context) {
|
|
44382
44399
|
if (this.toHighlight.length > 0) {
|
|
44383
44400
|
this.toHighlight.forEach((group) => {
|
|
44384
|
-
if (group.
|
|
44385
|
-
const frameRect = group.
|
|
44401
|
+
if (group.groupItem) {
|
|
44402
|
+
const frameRect = group.groupItem.getMbr();
|
|
44386
44403
|
frameRect.borderColor = FRAME_HIGHLIGHTER_BORDER_COLOR;
|
|
44387
44404
|
frameRect.strokeWidth = 0.3;
|
|
44388
44405
|
frameRect.render(context);
|
|
@@ -44477,7 +44494,7 @@ class AddFrame extends BoardTool {
|
|
|
44477
44494
|
return true;
|
|
44478
44495
|
}
|
|
44479
44496
|
addNextTo() {
|
|
44480
|
-
const framesInView = this.board.items.
|
|
44497
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame);
|
|
44481
44498
|
if (framesInView.length === 0) {
|
|
44482
44499
|
if (this.shape === "Custom") {
|
|
44483
44500
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -44489,7 +44506,7 @@ class AddFrame extends BoardTool {
|
|
|
44489
44506
|
}
|
|
44490
44507
|
this.transformToCenter();
|
|
44491
44508
|
} else {
|
|
44492
|
-
const frames = this.board.items.
|
|
44509
|
+
const frames = this.board.items.listAll().filter((frame2) => frame2 instanceof Frame && frame2 !== this.frame);
|
|
44493
44510
|
let nextTo = framesInView.reduce((rightest, frame2) => {
|
|
44494
44511
|
if (frame2.getMbr().right > rightest.getMbr().right) {
|
|
44495
44512
|
rightest = frame2;
|
|
@@ -45667,17 +45684,17 @@ function createCanvasDrawer(board) {
|
|
|
45667
45684
|
const realRight = realLeft + adjustedWidth;
|
|
45668
45685
|
const realBottom = realTop + adjustedHeight;
|
|
45669
45686
|
const containerMbr = new Mbr(realLeft, realTop, realRight, realBottom);
|
|
45670
|
-
const
|
|
45671
|
-
if (
|
|
45687
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(containerMbr.left, containerMbr.top, containerMbr.right, containerMbr.bottom);
|
|
45688
|
+
if (groups) {
|
|
45672
45689
|
drawnItemsMap?.forEach(({ mbr }) => {
|
|
45673
45690
|
mbr.transform(currMatrix);
|
|
45674
45691
|
});
|
|
45675
|
-
|
|
45692
|
+
groups.forEach((group) => {
|
|
45676
45693
|
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
45677
|
-
if (item
|
|
45694
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
45678
45695
|
return;
|
|
45679
45696
|
}
|
|
45680
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(
|
|
45697
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
45681
45698
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
45682
45699
|
removeHighlighted(key);
|
|
45683
45700
|
highlightedDivs.set(key, div);
|
|
@@ -47766,7 +47783,7 @@ class Tools extends ToolContext {
|
|
|
47766
47783
|
this.subject.publish(this);
|
|
47767
47784
|
}
|
|
47768
47785
|
sortFrames() {
|
|
47769
|
-
const frames = this.board.items.
|
|
47786
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame);
|
|
47770
47787
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
47771
47788
|
const mbr1 = fr1.getMbr();
|
|
47772
47789
|
const mbr2 = fr2.getMbr();
|
|
@@ -51853,9 +51870,9 @@ function updateFrameChildren({
|
|
|
51853
51870
|
board,
|
|
51854
51871
|
nestingHighlighter
|
|
51855
51872
|
}) {
|
|
51856
|
-
const
|
|
51873
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
51857
51874
|
board.selection.items.list().forEach((item) => {
|
|
51858
|
-
if (item
|
|
51875
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
51859
51876
|
const currMbr = item.getMbr();
|
|
51860
51877
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
51861
51878
|
itemsToCheck.forEach((currItem) => {
|
|
@@ -51866,9 +51883,9 @@ function updateFrameChildren({
|
|
|
51866
51883
|
}
|
|
51867
51884
|
});
|
|
51868
51885
|
} else {
|
|
51869
|
-
|
|
51870
|
-
if (
|
|
51871
|
-
nestingHighlighter.add(
|
|
51886
|
+
groups.forEach((group) => {
|
|
51887
|
+
if (group.handleNesting(item)) {
|
|
51888
|
+
nestingHighlighter.add(group, item);
|
|
51872
51889
|
} else {
|
|
51873
51890
|
nestingHighlighter.remove(item);
|
|
51874
51891
|
}
|
|
@@ -52387,9 +52404,7 @@ class BoardSelection {
|
|
|
52387
52404
|
}
|
|
52388
52405
|
addAll() {
|
|
52389
52406
|
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
52390
|
-
const frames = this.board.items.listFrames().filter((item) => !item.transformation.isLocked);
|
|
52391
52407
|
this.add(items);
|
|
52392
|
-
this.add(frames);
|
|
52393
52408
|
this.setContext("SelectByRect");
|
|
52394
52409
|
}
|
|
52395
52410
|
remove(value) {
|
|
@@ -52818,38 +52833,38 @@ class BoardSelection {
|
|
|
52818
52833
|
}, undefined);
|
|
52819
52834
|
if (selectedMbr) {
|
|
52820
52835
|
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
52821
|
-
const
|
|
52822
|
-
|
|
52836
|
+
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
52837
|
+
enclosedGroups.forEach((group) => {
|
|
52823
52838
|
selected.forEach((item) => {
|
|
52824
|
-
if (
|
|
52825
|
-
selectedMap[item.getId()].nested =
|
|
52839
|
+
if (group.handleNesting(item)) {
|
|
52840
|
+
selectedMap[item.getId()].nested = group;
|
|
52826
52841
|
}
|
|
52827
52842
|
});
|
|
52828
52843
|
});
|
|
52829
52844
|
Object.values(selectedMap).forEach((val) => {
|
|
52830
|
-
const
|
|
52831
|
-
const
|
|
52832
|
-
const parentFrameId = isParentFrame ? parentFrame.getId() : null;
|
|
52845
|
+
const parentGroup = this.board.items.getById(val.item.parent);
|
|
52846
|
+
const parentGroupId = parentGroup?.getId();
|
|
52833
52847
|
if (val.nested) {
|
|
52834
|
-
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !==
|
|
52835
|
-
if (
|
|
52836
|
-
|
|
52848
|
+
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentGroupId);
|
|
52849
|
+
if (parentGroupId && isRemoveChildFromFrame) {
|
|
52850
|
+
parentGroup?.removeChildItems([val.item]);
|
|
52837
52851
|
}
|
|
52838
52852
|
val.nested.addChildItems([val.item]);
|
|
52839
52853
|
} else if (val.item.parent !== "Board") {
|
|
52840
|
-
if (
|
|
52841
|
-
|
|
52854
|
+
if (parentGroupId) {
|
|
52855
|
+
parentGroup?.removeChildItems([val.item]);
|
|
52842
52856
|
} else {
|
|
52843
52857
|
console.warn(`Didnt find frame with id ${val.item.parent}`);
|
|
52844
52858
|
}
|
|
52845
52859
|
}
|
|
52846
|
-
|
|
52847
|
-
|
|
52848
|
-
const
|
|
52849
|
-
const
|
|
52850
|
-
const
|
|
52860
|
+
const childrenIds = val.item.getChildrenIds();
|
|
52861
|
+
if (childrenIds && checkFrames) {
|
|
52862
|
+
const currGroup = val.item;
|
|
52863
|
+
const currMbr = currGroup.getMbr();
|
|
52864
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
52865
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
52851
52866
|
const uniqueItems = new Set;
|
|
52852
|
-
const toCheck = [...children, ...
|
|
52867
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
52853
52868
|
const id = item.getId();
|
|
52854
52869
|
if (uniqueItems.has(id)) {
|
|
52855
52870
|
return false;
|
|
@@ -52857,7 +52872,7 @@ class BoardSelection {
|
|
|
52857
52872
|
uniqueItems.add(id);
|
|
52858
52873
|
return true;
|
|
52859
52874
|
});
|
|
52860
|
-
|
|
52875
|
+
currGroup.emitNesting(toCheck);
|
|
52861
52876
|
}
|
|
52862
52877
|
});
|
|
52863
52878
|
}
|
|
@@ -54400,13 +54415,9 @@ class LayeredIndex {
|
|
|
54400
54415
|
class SpatialIndex {
|
|
54401
54416
|
subject = new Subject;
|
|
54402
54417
|
itemsArray = [];
|
|
54403
|
-
framesArray = [];
|
|
54404
54418
|
itemsIndex = new LayeredIndex((item) => {
|
|
54405
54419
|
return this.itemsArray.indexOf(item);
|
|
54406
54420
|
});
|
|
54407
|
-
framesIndex = new LayeredIndex((item) => {
|
|
54408
|
-
return this.framesArray.indexOf(item);
|
|
54409
|
-
});
|
|
54410
54421
|
Mbr = new Mbr;
|
|
54411
54422
|
items;
|
|
54412
54423
|
constructor(view, pointer) {
|
|
@@ -54414,23 +54425,14 @@ class SpatialIndex {
|
|
|
54414
54425
|
}
|
|
54415
54426
|
clear() {
|
|
54416
54427
|
this.itemsArray = [];
|
|
54417
|
-
this.framesArray = [];
|
|
54418
54428
|
this.itemsIndex = new LayeredIndex((item) => {
|
|
54419
54429
|
return this.itemsArray.indexOf(item);
|
|
54420
54430
|
});
|
|
54421
|
-
this.framesIndex = new LayeredIndex((item) => {
|
|
54422
|
-
return this.framesArray.indexOf(item);
|
|
54423
|
-
});
|
|
54424
54431
|
this.Mbr = new Mbr;
|
|
54425
54432
|
}
|
|
54426
54433
|
insert(item) {
|
|
54427
|
-
|
|
54428
|
-
|
|
54429
|
-
this.framesIndex.insert(item);
|
|
54430
|
-
} else {
|
|
54431
|
-
this.itemsArray.push(item);
|
|
54432
|
-
this.itemsIndex.insert(item);
|
|
54433
|
-
}
|
|
54434
|
+
this.itemsArray.push(item);
|
|
54435
|
+
this.itemsIndex.insert(item);
|
|
54434
54436
|
if (conf.isNode()) {
|
|
54435
54437
|
return;
|
|
54436
54438
|
}
|
|
@@ -54443,11 +54445,7 @@ class SpatialIndex {
|
|
|
54443
54445
|
this.subject.publish(this.items);
|
|
54444
54446
|
}
|
|
54445
54447
|
change = (item) => {
|
|
54446
|
-
|
|
54447
|
-
this.framesIndex.change(item);
|
|
54448
|
-
} else {
|
|
54449
|
-
this.itemsIndex.change(item);
|
|
54450
|
-
}
|
|
54448
|
+
this.itemsIndex.change(item);
|
|
54451
54449
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
54452
54450
|
this.Mbr = item.getMbr().copy();
|
|
54453
54451
|
} else {
|
|
@@ -54464,39 +54462,22 @@ class SpatialIndex {
|
|
|
54464
54462
|
const parentFrame = this.items.getById(item.parent);
|
|
54465
54463
|
parentFrame?.removeChildItems(item);
|
|
54466
54464
|
}
|
|
54467
|
-
|
|
54468
|
-
|
|
54469
|
-
this.framesIndex.remove(item);
|
|
54470
|
-
} else {
|
|
54471
|
-
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
54472
|
-
this.itemsIndex.remove(item);
|
|
54473
|
-
}
|
|
54465
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
54466
|
+
this.itemsIndex.remove(item);
|
|
54474
54467
|
this.Mbr = new Mbr;
|
|
54475
|
-
|
|
54476
|
-
allItems.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
54468
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
54477
54469
|
this.subject.publish(this.items);
|
|
54478
54470
|
}
|
|
54479
54471
|
copy() {
|
|
54480
|
-
|
|
54472
|
+
return this.itemsArray.map((item) => ({
|
|
54481
54473
|
...item.serialize(true),
|
|
54482
54474
|
id: item.getId()
|
|
54483
54475
|
}));
|
|
54484
|
-
const framesData = this.framesArray.map((item) => ({
|
|
54485
|
-
...item.serialize(),
|
|
54486
|
-
id: item.getId()
|
|
54487
|
-
}));
|
|
54488
|
-
return [...framesData, ...itemsData];
|
|
54489
54476
|
}
|
|
54490
54477
|
moveToZIndex(item, zIndex) {
|
|
54491
|
-
|
|
54492
|
-
|
|
54493
|
-
|
|
54494
|
-
this.framesArray.splice(zIndex, 0, item);
|
|
54495
|
-
} else {
|
|
54496
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
54497
|
-
this.itemsArray.splice(index2, 1);
|
|
54498
|
-
this.itemsArray.splice(zIndex, 0, item);
|
|
54499
|
-
}
|
|
54478
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
54479
|
+
this.itemsArray.splice(index2, 1);
|
|
54480
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
54500
54481
|
this.change(item);
|
|
54501
54482
|
this.subject.publish(this.items);
|
|
54502
54483
|
}
|
|
@@ -54510,17 +54491,10 @@ class SpatialIndex {
|
|
|
54510
54491
|
this.itemsArray.forEach(this.change.bind(this));
|
|
54511
54492
|
}
|
|
54512
54493
|
sendToBack(item, shouldPublish = true) {
|
|
54513
|
-
|
|
54514
|
-
|
|
54515
|
-
|
|
54516
|
-
|
|
54517
|
-
this.framesIndex.change(item);
|
|
54518
|
-
} else {
|
|
54519
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
54520
|
-
this.itemsArray.splice(index2, 1);
|
|
54521
|
-
this.itemsArray.unshift(item);
|
|
54522
|
-
this.itemsIndex.change(item);
|
|
54523
|
-
}
|
|
54494
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
54495
|
+
this.itemsArray.splice(index2, 1);
|
|
54496
|
+
this.itemsArray.unshift(item);
|
|
54497
|
+
this.itemsIndex.change(item);
|
|
54524
54498
|
if (shouldPublish) {
|
|
54525
54499
|
this.subject.publish(this.items);
|
|
54526
54500
|
}
|
|
@@ -54536,17 +54510,10 @@ class SpatialIndex {
|
|
|
54536
54510
|
this.itemsArray.forEach(this.change.bind(this));
|
|
54537
54511
|
}
|
|
54538
54512
|
bringToFront(item, shouldPublish = true) {
|
|
54539
|
-
|
|
54540
|
-
|
|
54541
|
-
|
|
54542
|
-
|
|
54543
|
-
this.framesIndex.change(item);
|
|
54544
|
-
} else {
|
|
54545
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
54546
|
-
this.itemsArray.splice(index2, 1);
|
|
54547
|
-
this.itemsArray.push(item);
|
|
54548
|
-
this.itemsIndex.change(item);
|
|
54549
|
-
}
|
|
54513
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
54514
|
+
this.itemsArray.splice(index2, 1);
|
|
54515
|
+
this.itemsArray.push(item);
|
|
54516
|
+
this.itemsIndex.change(item);
|
|
54550
54517
|
if (shouldPublish) {
|
|
54551
54518
|
this.subject.publish(this.items);
|
|
54552
54519
|
}
|
|
@@ -54585,37 +54552,24 @@ class SpatialIndex {
|
|
|
54585
54552
|
if (item) {
|
|
54586
54553
|
return item;
|
|
54587
54554
|
}
|
|
54588
|
-
const frame = this.framesArray.find((frame2) => frame2.getId() === id);
|
|
54589
|
-
return frame;
|
|
54590
54555
|
}
|
|
54591
54556
|
findById(id) {
|
|
54592
54557
|
return this.getById(id);
|
|
54593
54558
|
}
|
|
54594
54559
|
getEnclosed(left, top, right, bottom) {
|
|
54595
54560
|
const mbr = new Mbr(left, top, right, bottom);
|
|
54596
|
-
|
|
54597
|
-
const enclosedFrames = this.framesIndex.getEnclosed(mbr);
|
|
54598
|
-
return enclosedFrames.concat(enclosedItems);
|
|
54561
|
+
return this.itemsIndex.getEnclosed(mbr);
|
|
54599
54562
|
}
|
|
54600
54563
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
54601
54564
|
const mbr = new Mbr(left, top, right, bottom);
|
|
54602
|
-
|
|
54603
|
-
const enclosedOrCrossedFrames = this.framesIndex.getEnclosedOrCrossedBy(mbr);
|
|
54604
|
-
return enclosedOrCrossedFrames.concat(enclosedOrCrossedItems);
|
|
54565
|
+
return this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
54605
54566
|
}
|
|
54606
54567
|
getUnderPoint(point5, tolerace = 5) {
|
|
54607
|
-
|
|
54608
|
-
const framesUnderPoint = this.framesIndex.getUnderPoint(point5, tolerace);
|
|
54609
|
-
return [...framesUnderPoint, ...itemsUnderPoint];
|
|
54568
|
+
return this.itemsIndex.getUnderPoint(point5, tolerace);
|
|
54610
54569
|
}
|
|
54611
54570
|
getRectsEnclosedOrCrossed(left, top, right, bottom) {
|
|
54612
54571
|
const mbr = new Mbr(left, top, right, bottom);
|
|
54613
|
-
|
|
54614
|
-
const woFrames = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
54615
|
-
return [...woFrames, ...frames];
|
|
54616
|
-
}
|
|
54617
|
-
getFramesEnclosedOrCrossed(left, top, right, bottom) {
|
|
54618
|
-
return this.framesIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
54572
|
+
return this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
54619
54573
|
}
|
|
54620
54574
|
getItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
54621
54575
|
return this.itemsIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
@@ -54628,44 +54582,28 @@ class SpatialIndex {
|
|
|
54628
54582
|
}
|
|
54629
54583
|
getNearestTo(point5, maxItems, filter, maxDistance) {
|
|
54630
54584
|
const nearestItems = this.itemsIndex.getNearestTo(point5, maxItems, filter, maxDistance);
|
|
54631
|
-
|
|
54632
|
-
const combined = nearestItems.concat(nearestFrames);
|
|
54633
|
-
combined.sort((aa, bb) => {
|
|
54585
|
+
nearestItems.sort((aa, bb) => {
|
|
54634
54586
|
const distA = point5.getDistance(aa.getMbr().getCenter());
|
|
54635
54587
|
const distB = point5.getDistance(bb.getMbr().getCenter());
|
|
54636
54588
|
return distA - distB;
|
|
54637
54589
|
});
|
|
54638
|
-
return
|
|
54590
|
+
return nearestItems.slice(0, maxItems);
|
|
54639
54591
|
}
|
|
54640
54592
|
list() {
|
|
54641
54593
|
return this.itemsArray.concat();
|
|
54642
54594
|
}
|
|
54643
|
-
listFrames() {
|
|
54644
|
-
return this.framesArray.concat();
|
|
54645
|
-
}
|
|
54646
54595
|
getZIndex(item) {
|
|
54647
|
-
|
|
54648
|
-
return this.framesArray.indexOf(item);
|
|
54649
|
-
} else {
|
|
54650
|
-
return this.itemsArray.indexOf(item);
|
|
54651
|
-
}
|
|
54596
|
+
return this.itemsArray.indexOf(item);
|
|
54652
54597
|
}
|
|
54653
54598
|
getLastZIndex() {
|
|
54654
|
-
return this.itemsArray.length
|
|
54599
|
+
return this.itemsArray.length - 1;
|
|
54655
54600
|
}
|
|
54656
54601
|
getByZIndex(index2) {
|
|
54657
|
-
const totalItems = this.itemsArray.length + this.framesArray.length;
|
|
54658
54602
|
if (index2 < this.itemsArray.length) {
|
|
54659
54603
|
return this.itemsArray[index2];
|
|
54660
|
-
} else if (index2 < totalItems) {
|
|
54661
|
-
return this.framesArray[index2 - this.itemsArray.length];
|
|
54662
54604
|
} else {
|
|
54663
54605
|
const lastIndex = this.getLastZIndex();
|
|
54664
|
-
|
|
54665
|
-
return this.framesArray[lastIndex];
|
|
54666
|
-
} else {
|
|
54667
|
-
return this.itemsArray[lastIndex];
|
|
54668
|
-
}
|
|
54606
|
+
return this.itemsArray[lastIndex];
|
|
54669
54607
|
}
|
|
54670
54608
|
}
|
|
54671
54609
|
}
|
|
@@ -54688,7 +54626,10 @@ class Items {
|
|
|
54688
54626
|
return this.index.list();
|
|
54689
54627
|
}
|
|
54690
54628
|
listFrames() {
|
|
54691
|
-
return this.index.
|
|
54629
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
54630
|
+
}
|
|
54631
|
+
listGroupItems() {
|
|
54632
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
54692
54633
|
}
|
|
54693
54634
|
getById(id) {
|
|
54694
54635
|
return this.index.getById(id);
|
|
@@ -54702,8 +54643,8 @@ class Items {
|
|
|
54702
54643
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
54703
54644
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
54704
54645
|
}
|
|
54705
|
-
|
|
54706
|
-
return this.index.
|
|
54646
|
+
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
54647
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.getChildrenIds());
|
|
54707
54648
|
}
|
|
54708
54649
|
getUnderPoint(point5, tolerance = 5) {
|
|
54709
54650
|
return this.index.getUnderPoint(point5, tolerance);
|
|
@@ -54719,9 +54660,9 @@ class Items {
|
|
|
54719
54660
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
54720
54661
|
return this.index.getItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
54721
54662
|
}
|
|
54722
|
-
|
|
54663
|
+
getGroupItemsInView() {
|
|
54723
54664
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
54724
|
-
return this.
|
|
54665
|
+
return this.getGroupItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
54725
54666
|
}
|
|
54726
54667
|
getComments() {
|
|
54727
54668
|
return this.index.getComments();
|
|
@@ -54759,11 +54700,7 @@ class Items {
|
|
|
54759
54700
|
if (nearest) {
|
|
54760
54701
|
return [nearest];
|
|
54761
54702
|
}
|
|
54762
|
-
|
|
54763
|
-
if (frames.length === 0 && unmodifiedSize !== 16) {
|
|
54764
|
-
return this.getUnderPointer(16);
|
|
54765
|
-
}
|
|
54766
|
-
return frames;
|
|
54703
|
+
return [];
|
|
54767
54704
|
}
|
|
54768
54705
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
54769
54706
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
@@ -54814,41 +54751,39 @@ class Items {
|
|
|
54814
54751
|
});
|
|
54815
54752
|
}
|
|
54816
54753
|
render(context) {
|
|
54817
|
-
const
|
|
54818
|
-
|
|
54819
|
-
|
|
54820
|
-
|
|
54821
|
-
|
|
54822
|
-
frame.getChildrenIds().map((id) => this.getById(id)).forEach((child) => {
|
|
54823
|
-
if (child) {
|
|
54824
|
-
frameChildrenIds.push(child.getId());
|
|
54825
|
-
child.render(context);
|
|
54826
|
-
}
|
|
54827
|
-
});
|
|
54754
|
+
const items = this.getItemsInView();
|
|
54755
|
+
items.forEach((item) => {
|
|
54756
|
+
if (item.parent === "Board") {
|
|
54757
|
+
item.render(context);
|
|
54758
|
+
}
|
|
54828
54759
|
});
|
|
54829
|
-
rest.filter((item) => !frameChildrenIds.includes(item.getId())).forEach((item) => item.render(context));
|
|
54830
|
-
frames.forEach((frame) => frame.renderBorders(context));
|
|
54831
|
-
frames.forEach((frame) => frame.renderName(context));
|
|
54832
54760
|
}
|
|
54833
54761
|
renderHTML(documentFactory) {
|
|
54834
|
-
const
|
|
54835
|
-
|
|
54836
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
54762
|
+
const items = this.getItemsInView();
|
|
54763
|
+
return this.getHTML(documentFactory, items);
|
|
54837
54764
|
}
|
|
54838
54765
|
getWholeHTML(documentFactory) {
|
|
54839
|
-
const
|
|
54840
|
-
|
|
54841
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
54766
|
+
const items = this.listAll();
|
|
54767
|
+
return this.getHTML(documentFactory, items);
|
|
54842
54768
|
}
|
|
54843
|
-
getHTML(documentFactory,
|
|
54844
|
-
const lowestCoordinates =
|
|
54769
|
+
getHTML(documentFactory, items) {
|
|
54770
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
54845
54771
|
left: Math.min(acc.left, mbr.left),
|
|
54846
54772
|
top: Math.min(acc.top, mbr.top)
|
|
54847
54773
|
}), { left: 0, top: 0 });
|
|
54774
|
+
const groups = [];
|
|
54775
|
+
const rest = [];
|
|
54776
|
+
items.forEach((item) => {
|
|
54777
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
54778
|
+
groups.push(item);
|
|
54779
|
+
} else {
|
|
54780
|
+
rest.push(item);
|
|
54781
|
+
}
|
|
54782
|
+
});
|
|
54848
54783
|
const childrenMap = new Map;
|
|
54849
|
-
const
|
|
54850
|
-
|
|
54851
|
-
const html4 =
|
|
54784
|
+
const GroupsHTML = groups.map((group) => {
|
|
54785
|
+
group.getChildrenIds().forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
54786
|
+
const html4 = group.renderHTML(documentFactory);
|
|
54852
54787
|
translateElementBy(html4, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
54853
54788
|
return html4;
|
|
54854
54789
|
});
|
|
@@ -54867,15 +54802,15 @@ class Items {
|
|
|
54867
54802
|
});
|
|
54868
54803
|
for (const item of restHTML) {
|
|
54869
54804
|
const parentFrameId = childrenMap.get(item.id);
|
|
54870
|
-
const
|
|
54871
|
-
if (
|
|
54872
|
-
positionRelatively(item,
|
|
54873
|
-
|
|
54805
|
+
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
54806
|
+
if (group) {
|
|
54807
|
+
positionRelatively(item, group);
|
|
54808
|
+
group.appendChild(item);
|
|
54874
54809
|
}
|
|
54875
54810
|
}
|
|
54876
54811
|
let result = "";
|
|
54877
|
-
for (const
|
|
54878
|
-
result +=
|
|
54812
|
+
for (const group of GroupsHTML) {
|
|
54813
|
+
result += group.outerHTML;
|
|
54879
54814
|
}
|
|
54880
54815
|
for (const item of restHTML) {
|
|
54881
54816
|
if (!childrenMap.get(item.id)) {
|
|
@@ -55520,24 +55455,24 @@ class Board {
|
|
|
55520
55455
|
}
|
|
55521
55456
|
handleNesting(items) {
|
|
55522
55457
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
55523
|
-
const
|
|
55458
|
+
const groupsMap = new Map;
|
|
55524
55459
|
arrayed.forEach((item) => {
|
|
55525
55460
|
const itemCenter = item.getMbr().getCenter();
|
|
55526
|
-
const
|
|
55527
|
-
if (!acc ||
|
|
55528
|
-
acc =
|
|
55461
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
55462
|
+
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
55463
|
+
acc = groupItem2;
|
|
55529
55464
|
}
|
|
55530
55465
|
return acc;
|
|
55531
55466
|
}, undefined);
|
|
55532
|
-
if (
|
|
55533
|
-
if (!
|
|
55534
|
-
|
|
55467
|
+
if (groupItem) {
|
|
55468
|
+
if (!groupsMap.has(groupItem)) {
|
|
55469
|
+
groupsMap.set(groupItem, []);
|
|
55535
55470
|
}
|
|
55536
|
-
|
|
55471
|
+
groupsMap.get(groupItem)?.push(item);
|
|
55537
55472
|
}
|
|
55538
55473
|
});
|
|
55539
|
-
|
|
55540
|
-
|
|
55474
|
+
groupsMap.forEach((items2, group) => {
|
|
55475
|
+
group.addChildItems(items2);
|
|
55541
55476
|
});
|
|
55542
55477
|
}
|
|
55543
55478
|
createItem(id, data) {
|
|
@@ -56250,7 +56185,7 @@ class Board {
|
|
|
56250
56185
|
return this.items.findById(item.getId()) !== undefined;
|
|
56251
56186
|
}
|
|
56252
56187
|
getMaxFrameSerial() {
|
|
56253
|
-
const existingNames = this.items.
|
|
56188
|
+
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
56254
56189
|
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);
|
|
56255
56190
|
}
|
|
56256
56191
|
setInterfaceType(interfaceType) {
|