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/esm/browser.js
CHANGED
|
@@ -19502,6 +19502,7 @@ class BaseItem extends Mbr {
|
|
|
19502
19502
|
children = null;
|
|
19503
19503
|
canBeNested = true;
|
|
19504
19504
|
transformationRenderBlock = undefined;
|
|
19505
|
+
childItems = null;
|
|
19505
19506
|
board;
|
|
19506
19507
|
id;
|
|
19507
19508
|
subject = new Subject;
|
|
@@ -19532,6 +19533,9 @@ class BaseItem extends Mbr {
|
|
|
19532
19533
|
this.getRichText()?.setId(id);
|
|
19533
19534
|
return this;
|
|
19534
19535
|
}
|
|
19536
|
+
getChildrenIds() {
|
|
19537
|
+
return this.children;
|
|
19538
|
+
}
|
|
19535
19539
|
addChildItems(children) {
|
|
19536
19540
|
if (!this.children) {
|
|
19537
19541
|
return;
|
|
@@ -19598,15 +19602,20 @@ class BaseItem extends Mbr {
|
|
|
19598
19602
|
if (!this.children) {
|
|
19599
19603
|
return;
|
|
19600
19604
|
}
|
|
19601
|
-
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
+
const updatedChildItems = [];
|
|
19606
|
+
children.forEach((childId) => {
|
|
19607
|
+
const foundItem = this.board.items.getById(childId);
|
|
19608
|
+
if (foundItem) {
|
|
19609
|
+
updatedChildItems.push(foundItem);
|
|
19610
|
+
}
|
|
19611
|
+
if (this.parent !== childId && this.getId() !== childId) {
|
|
19612
|
+
if (!this.children.includes(childId) && foundItem) {
|
|
19605
19613
|
foundItem.parent = this.getId();
|
|
19606
19614
|
}
|
|
19607
19615
|
}
|
|
19608
19616
|
});
|
|
19609
19617
|
this.children = children;
|
|
19618
|
+
this.childItems = updatedChildItems;
|
|
19610
19619
|
this.updateMbr();
|
|
19611
19620
|
this.subject.publish(this);
|
|
19612
19621
|
}
|
|
@@ -19682,7 +19691,13 @@ class BaseItem extends Mbr {
|
|
|
19682
19691
|
getPath() {
|
|
19683
19692
|
return new Path(this.getMbr().getLines());
|
|
19684
19693
|
}
|
|
19685
|
-
render(context) {
|
|
19694
|
+
render(context) {
|
|
19695
|
+
if (this.childItems) {
|
|
19696
|
+
this.childItems.forEach((child) => {
|
|
19697
|
+
child.render(context);
|
|
19698
|
+
});
|
|
19699
|
+
}
|
|
19700
|
+
}
|
|
19686
19701
|
renderHTML(documentFactory) {
|
|
19687
19702
|
return documentFactory.createElement("div");
|
|
19688
19703
|
}
|
|
@@ -38711,8 +38726,10 @@ class Frame extends BaseItem {
|
|
|
38711
38726
|
if (this.transformationRenderBlock) {
|
|
38712
38727
|
return;
|
|
38713
38728
|
}
|
|
38714
|
-
this.
|
|
38715
|
-
|
|
38729
|
+
this.renderPath(context);
|
|
38730
|
+
super.render(context);
|
|
38731
|
+
this.renderBorders(context);
|
|
38732
|
+
this.renderName(context);
|
|
38716
38733
|
}
|
|
38717
38734
|
renderName(context) {
|
|
38718
38735
|
if (this.transformationRenderBlock) {
|
|
@@ -41828,8 +41845,8 @@ class NestingHighlighter extends Tool {
|
|
|
41828
41845
|
listAll() {
|
|
41829
41846
|
return this.toHighlight;
|
|
41830
41847
|
}
|
|
41831
|
-
add(
|
|
41832
|
-
const existing = this.toHighlight.find((group) => group.
|
|
41848
|
+
add(groupItem, children) {
|
|
41849
|
+
const existing = this.toHighlight.find((group) => group.groupItem === groupItem);
|
|
41833
41850
|
const array = Array.isArray(children) ? children : [children];
|
|
41834
41851
|
if (existing) {
|
|
41835
41852
|
array.forEach((child) => {
|
|
@@ -41838,7 +41855,7 @@ class NestingHighlighter extends Tool {
|
|
|
41838
41855
|
}
|
|
41839
41856
|
});
|
|
41840
41857
|
} else {
|
|
41841
|
-
this.toHighlight.push({
|
|
41858
|
+
this.toHighlight.push({ groupItem, children: array });
|
|
41842
41859
|
}
|
|
41843
41860
|
}
|
|
41844
41861
|
addSingleItem(item) {
|
|
@@ -41853,8 +41870,8 @@ class NestingHighlighter extends Tool {
|
|
|
41853
41870
|
render(context) {
|
|
41854
41871
|
if (this.toHighlight.length > 0) {
|
|
41855
41872
|
this.toHighlight.forEach((group) => {
|
|
41856
|
-
if (group.
|
|
41857
|
-
const frameRect = group.
|
|
41873
|
+
if (group.groupItem) {
|
|
41874
|
+
const frameRect = group.groupItem.getMbr();
|
|
41858
41875
|
frameRect.borderColor = FRAME_HIGHLIGHTER_BORDER_COLOR;
|
|
41859
41876
|
frameRect.strokeWidth = 0.3;
|
|
41860
41877
|
frameRect.render(context);
|
|
@@ -41949,7 +41966,7 @@ class AddFrame extends BoardTool {
|
|
|
41949
41966
|
return true;
|
|
41950
41967
|
}
|
|
41951
41968
|
addNextTo() {
|
|
41952
|
-
const framesInView = this.board.items.
|
|
41969
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame);
|
|
41953
41970
|
if (framesInView.length === 0) {
|
|
41954
41971
|
if (this.shape === "Custom") {
|
|
41955
41972
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -41961,7 +41978,7 @@ class AddFrame extends BoardTool {
|
|
|
41961
41978
|
}
|
|
41962
41979
|
this.transformToCenter();
|
|
41963
41980
|
} else {
|
|
41964
|
-
const frames = this.board.items.
|
|
41981
|
+
const frames = this.board.items.listAll().filter((frame2) => frame2 instanceof Frame && frame2 !== this.frame);
|
|
41965
41982
|
let nextTo = framesInView.reduce((rightest, frame2) => {
|
|
41966
41983
|
if (frame2.getMbr().right > rightest.getMbr().right) {
|
|
41967
41984
|
rightest = frame2;
|
|
@@ -43139,17 +43156,17 @@ function createCanvasDrawer(board) {
|
|
|
43139
43156
|
const realRight = realLeft + adjustedWidth;
|
|
43140
43157
|
const realBottom = realTop + adjustedHeight;
|
|
43141
43158
|
const containerMbr = new Mbr(realLeft, realTop, realRight, realBottom);
|
|
43142
|
-
const
|
|
43143
|
-
if (
|
|
43159
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(containerMbr.left, containerMbr.top, containerMbr.right, containerMbr.bottom);
|
|
43160
|
+
if (groups) {
|
|
43144
43161
|
drawnItemsMap?.forEach(({ mbr }) => {
|
|
43145
43162
|
mbr.transform(currMatrix);
|
|
43146
43163
|
});
|
|
43147
|
-
|
|
43164
|
+
groups.forEach((group) => {
|
|
43148
43165
|
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
43149
|
-
if (item
|
|
43166
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
43150
43167
|
return;
|
|
43151
43168
|
}
|
|
43152
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(
|
|
43169
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
43153
43170
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
43154
43171
|
removeHighlighted(key);
|
|
43155
43172
|
highlightedDivs.set(key, div);
|
|
@@ -45238,7 +45255,7 @@ class Tools extends ToolContext {
|
|
|
45238
45255
|
this.subject.publish(this);
|
|
45239
45256
|
}
|
|
45240
45257
|
sortFrames() {
|
|
45241
|
-
const frames = this.board.items.
|
|
45258
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame);
|
|
45242
45259
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
45243
45260
|
const mbr1 = fr1.getMbr();
|
|
45244
45261
|
const mbr2 = fr2.getMbr();
|
|
@@ -49325,9 +49342,9 @@ function updateFrameChildren({
|
|
|
49325
49342
|
board,
|
|
49326
49343
|
nestingHighlighter
|
|
49327
49344
|
}) {
|
|
49328
|
-
const
|
|
49345
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
49329
49346
|
board.selection.items.list().forEach((item) => {
|
|
49330
|
-
if (item
|
|
49347
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
49331
49348
|
const currMbr = item.getMbr();
|
|
49332
49349
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
49333
49350
|
itemsToCheck.forEach((currItem) => {
|
|
@@ -49338,9 +49355,9 @@ function updateFrameChildren({
|
|
|
49338
49355
|
}
|
|
49339
49356
|
});
|
|
49340
49357
|
} else {
|
|
49341
|
-
|
|
49342
|
-
if (
|
|
49343
|
-
nestingHighlighter.add(
|
|
49358
|
+
groups.forEach((group) => {
|
|
49359
|
+
if (group.handleNesting(item)) {
|
|
49360
|
+
nestingHighlighter.add(group, item);
|
|
49344
49361
|
} else {
|
|
49345
49362
|
nestingHighlighter.remove(item);
|
|
49346
49363
|
}
|
|
@@ -49859,9 +49876,7 @@ class BoardSelection {
|
|
|
49859
49876
|
}
|
|
49860
49877
|
addAll() {
|
|
49861
49878
|
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
49862
|
-
const frames = this.board.items.listFrames().filter((item) => !item.transformation.isLocked);
|
|
49863
49879
|
this.add(items);
|
|
49864
|
-
this.add(frames);
|
|
49865
49880
|
this.setContext("SelectByRect");
|
|
49866
49881
|
}
|
|
49867
49882
|
remove(value) {
|
|
@@ -50290,38 +50305,38 @@ class BoardSelection {
|
|
|
50290
50305
|
}, undefined);
|
|
50291
50306
|
if (selectedMbr) {
|
|
50292
50307
|
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
50293
|
-
const
|
|
50294
|
-
|
|
50308
|
+
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
50309
|
+
enclosedGroups.forEach((group) => {
|
|
50295
50310
|
selected.forEach((item) => {
|
|
50296
|
-
if (
|
|
50297
|
-
selectedMap[item.getId()].nested =
|
|
50311
|
+
if (group.handleNesting(item)) {
|
|
50312
|
+
selectedMap[item.getId()].nested = group;
|
|
50298
50313
|
}
|
|
50299
50314
|
});
|
|
50300
50315
|
});
|
|
50301
50316
|
Object.values(selectedMap).forEach((val) => {
|
|
50302
|
-
const
|
|
50303
|
-
const
|
|
50304
|
-
const parentFrameId = isParentFrame ? parentFrame.getId() : null;
|
|
50317
|
+
const parentGroup = this.board.items.getById(val.item.parent);
|
|
50318
|
+
const parentGroupId = parentGroup?.getId();
|
|
50305
50319
|
if (val.nested) {
|
|
50306
|
-
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !==
|
|
50307
|
-
if (
|
|
50308
|
-
|
|
50320
|
+
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentGroupId);
|
|
50321
|
+
if (parentGroupId && isRemoveChildFromFrame) {
|
|
50322
|
+
parentGroup?.removeChildItems([val.item]);
|
|
50309
50323
|
}
|
|
50310
50324
|
val.nested.addChildItems([val.item]);
|
|
50311
50325
|
} else if (val.item.parent !== "Board") {
|
|
50312
|
-
if (
|
|
50313
|
-
|
|
50326
|
+
if (parentGroupId) {
|
|
50327
|
+
parentGroup?.removeChildItems([val.item]);
|
|
50314
50328
|
} else {
|
|
50315
50329
|
console.warn(`Didnt find frame with id ${val.item.parent}`);
|
|
50316
50330
|
}
|
|
50317
50331
|
}
|
|
50318
|
-
|
|
50319
|
-
|
|
50320
|
-
const
|
|
50321
|
-
const
|
|
50322
|
-
const
|
|
50332
|
+
const childrenIds = val.item.getChildrenIds();
|
|
50333
|
+
if (childrenIds && checkFrames) {
|
|
50334
|
+
const currGroup = val.item;
|
|
50335
|
+
const currMbr = currGroup.getMbr();
|
|
50336
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
50337
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
50323
50338
|
const uniqueItems = new Set;
|
|
50324
|
-
const toCheck = [...children, ...
|
|
50339
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
50325
50340
|
const id = item.getId();
|
|
50326
50341
|
if (uniqueItems.has(id)) {
|
|
50327
50342
|
return false;
|
|
@@ -50329,7 +50344,7 @@ class BoardSelection {
|
|
|
50329
50344
|
uniqueItems.add(id);
|
|
50330
50345
|
return true;
|
|
50331
50346
|
});
|
|
50332
|
-
|
|
50347
|
+
currGroup.emitNesting(toCheck);
|
|
50333
50348
|
}
|
|
50334
50349
|
});
|
|
50335
50350
|
}
|
|
@@ -51939,13 +51954,9 @@ class LayeredIndex {
|
|
|
51939
51954
|
class SpatialIndex {
|
|
51940
51955
|
subject = new Subject;
|
|
51941
51956
|
itemsArray = [];
|
|
51942
|
-
framesArray = [];
|
|
51943
51957
|
itemsIndex = new LayeredIndex((item) => {
|
|
51944
51958
|
return this.itemsArray.indexOf(item);
|
|
51945
51959
|
});
|
|
51946
|
-
framesIndex = new LayeredIndex((item) => {
|
|
51947
|
-
return this.framesArray.indexOf(item);
|
|
51948
|
-
});
|
|
51949
51960
|
Mbr = new Mbr;
|
|
51950
51961
|
items;
|
|
51951
51962
|
constructor(view, pointer) {
|
|
@@ -51953,23 +51964,14 @@ class SpatialIndex {
|
|
|
51953
51964
|
}
|
|
51954
51965
|
clear() {
|
|
51955
51966
|
this.itemsArray = [];
|
|
51956
|
-
this.framesArray = [];
|
|
51957
51967
|
this.itemsIndex = new LayeredIndex((item) => {
|
|
51958
51968
|
return this.itemsArray.indexOf(item);
|
|
51959
51969
|
});
|
|
51960
|
-
this.framesIndex = new LayeredIndex((item) => {
|
|
51961
|
-
return this.framesArray.indexOf(item);
|
|
51962
|
-
});
|
|
51963
51970
|
this.Mbr = new Mbr;
|
|
51964
51971
|
}
|
|
51965
51972
|
insert(item) {
|
|
51966
|
-
|
|
51967
|
-
|
|
51968
|
-
this.framesIndex.insert(item);
|
|
51969
|
-
} else {
|
|
51970
|
-
this.itemsArray.push(item);
|
|
51971
|
-
this.itemsIndex.insert(item);
|
|
51972
|
-
}
|
|
51973
|
+
this.itemsArray.push(item);
|
|
51974
|
+
this.itemsIndex.insert(item);
|
|
51973
51975
|
if (conf.isNode()) {
|
|
51974
51976
|
return;
|
|
51975
51977
|
}
|
|
@@ -51982,11 +51984,7 @@ class SpatialIndex {
|
|
|
51982
51984
|
this.subject.publish(this.items);
|
|
51983
51985
|
}
|
|
51984
51986
|
change = (item) => {
|
|
51985
|
-
|
|
51986
|
-
this.framesIndex.change(item);
|
|
51987
|
-
} else {
|
|
51988
|
-
this.itemsIndex.change(item);
|
|
51989
|
-
}
|
|
51987
|
+
this.itemsIndex.change(item);
|
|
51990
51988
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
51991
51989
|
this.Mbr = item.getMbr().copy();
|
|
51992
51990
|
} else {
|
|
@@ -52003,39 +52001,22 @@ class SpatialIndex {
|
|
|
52003
52001
|
const parentFrame = this.items.getById(item.parent);
|
|
52004
52002
|
parentFrame?.removeChildItems(item);
|
|
52005
52003
|
}
|
|
52006
|
-
|
|
52007
|
-
|
|
52008
|
-
this.framesIndex.remove(item);
|
|
52009
|
-
} else {
|
|
52010
|
-
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
52011
|
-
this.itemsIndex.remove(item);
|
|
52012
|
-
}
|
|
52004
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
52005
|
+
this.itemsIndex.remove(item);
|
|
52013
52006
|
this.Mbr = new Mbr;
|
|
52014
|
-
|
|
52015
|
-
allItems.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
52007
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
52016
52008
|
this.subject.publish(this.items);
|
|
52017
52009
|
}
|
|
52018
52010
|
copy() {
|
|
52019
|
-
|
|
52011
|
+
return this.itemsArray.map((item) => ({
|
|
52020
52012
|
...item.serialize(true),
|
|
52021
52013
|
id: item.getId()
|
|
52022
52014
|
}));
|
|
52023
|
-
const framesData = this.framesArray.map((item) => ({
|
|
52024
|
-
...item.serialize(),
|
|
52025
|
-
id: item.getId()
|
|
52026
|
-
}));
|
|
52027
|
-
return [...framesData, ...itemsData];
|
|
52028
52015
|
}
|
|
52029
52016
|
moveToZIndex(item, zIndex) {
|
|
52030
|
-
|
|
52031
|
-
|
|
52032
|
-
|
|
52033
|
-
this.framesArray.splice(zIndex, 0, item);
|
|
52034
|
-
} else {
|
|
52035
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
52036
|
-
this.itemsArray.splice(index2, 1);
|
|
52037
|
-
this.itemsArray.splice(zIndex, 0, item);
|
|
52038
|
-
}
|
|
52017
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
52018
|
+
this.itemsArray.splice(index2, 1);
|
|
52019
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
52039
52020
|
this.change(item);
|
|
52040
52021
|
this.subject.publish(this.items);
|
|
52041
52022
|
}
|
|
@@ -52049,17 +52030,10 @@ class SpatialIndex {
|
|
|
52049
52030
|
this.itemsArray.forEach(this.change.bind(this));
|
|
52050
52031
|
}
|
|
52051
52032
|
sendToBack(item, shouldPublish = true) {
|
|
52052
|
-
|
|
52053
|
-
|
|
52054
|
-
|
|
52055
|
-
|
|
52056
|
-
this.framesIndex.change(item);
|
|
52057
|
-
} else {
|
|
52058
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
52059
|
-
this.itemsArray.splice(index2, 1);
|
|
52060
|
-
this.itemsArray.unshift(item);
|
|
52061
|
-
this.itemsIndex.change(item);
|
|
52062
|
-
}
|
|
52033
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
52034
|
+
this.itemsArray.splice(index2, 1);
|
|
52035
|
+
this.itemsArray.unshift(item);
|
|
52036
|
+
this.itemsIndex.change(item);
|
|
52063
52037
|
if (shouldPublish) {
|
|
52064
52038
|
this.subject.publish(this.items);
|
|
52065
52039
|
}
|
|
@@ -52075,17 +52049,10 @@ class SpatialIndex {
|
|
|
52075
52049
|
this.itemsArray.forEach(this.change.bind(this));
|
|
52076
52050
|
}
|
|
52077
52051
|
bringToFront(item, shouldPublish = true) {
|
|
52078
|
-
|
|
52079
|
-
|
|
52080
|
-
|
|
52081
|
-
|
|
52082
|
-
this.framesIndex.change(item);
|
|
52083
|
-
} else {
|
|
52084
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
52085
|
-
this.itemsArray.splice(index2, 1);
|
|
52086
|
-
this.itemsArray.push(item);
|
|
52087
|
-
this.itemsIndex.change(item);
|
|
52088
|
-
}
|
|
52052
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
52053
|
+
this.itemsArray.splice(index2, 1);
|
|
52054
|
+
this.itemsArray.push(item);
|
|
52055
|
+
this.itemsIndex.change(item);
|
|
52089
52056
|
if (shouldPublish) {
|
|
52090
52057
|
this.subject.publish(this.items);
|
|
52091
52058
|
}
|
|
@@ -52124,37 +52091,24 @@ class SpatialIndex {
|
|
|
52124
52091
|
if (item) {
|
|
52125
52092
|
return item;
|
|
52126
52093
|
}
|
|
52127
|
-
const frame = this.framesArray.find((frame2) => frame2.getId() === id);
|
|
52128
|
-
return frame;
|
|
52129
52094
|
}
|
|
52130
52095
|
findById(id) {
|
|
52131
52096
|
return this.getById(id);
|
|
52132
52097
|
}
|
|
52133
52098
|
getEnclosed(left, top, right, bottom) {
|
|
52134
52099
|
const mbr = new Mbr(left, top, right, bottom);
|
|
52135
|
-
|
|
52136
|
-
const enclosedFrames = this.framesIndex.getEnclosed(mbr);
|
|
52137
|
-
return enclosedFrames.concat(enclosedItems);
|
|
52100
|
+
return this.itemsIndex.getEnclosed(mbr);
|
|
52138
52101
|
}
|
|
52139
52102
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
52140
52103
|
const mbr = new Mbr(left, top, right, bottom);
|
|
52141
|
-
|
|
52142
|
-
const enclosedOrCrossedFrames = this.framesIndex.getEnclosedOrCrossedBy(mbr);
|
|
52143
|
-
return enclosedOrCrossedFrames.concat(enclosedOrCrossedItems);
|
|
52104
|
+
return this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
52144
52105
|
}
|
|
52145
52106
|
getUnderPoint(point5, tolerace = 5) {
|
|
52146
|
-
|
|
52147
|
-
const framesUnderPoint = this.framesIndex.getUnderPoint(point5, tolerace);
|
|
52148
|
-
return [...framesUnderPoint, ...itemsUnderPoint];
|
|
52107
|
+
return this.itemsIndex.getUnderPoint(point5, tolerace);
|
|
52149
52108
|
}
|
|
52150
52109
|
getRectsEnclosedOrCrossed(left, top, right, bottom) {
|
|
52151
52110
|
const mbr = new Mbr(left, top, right, bottom);
|
|
52152
|
-
|
|
52153
|
-
const woFrames = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
52154
|
-
return [...woFrames, ...frames];
|
|
52155
|
-
}
|
|
52156
|
-
getFramesEnclosedOrCrossed(left, top, right, bottom) {
|
|
52157
|
-
return this.framesIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
52111
|
+
return this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
52158
52112
|
}
|
|
52159
52113
|
getItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
52160
52114
|
return this.itemsIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
@@ -52167,44 +52121,28 @@ class SpatialIndex {
|
|
|
52167
52121
|
}
|
|
52168
52122
|
getNearestTo(point5, maxItems, filter, maxDistance) {
|
|
52169
52123
|
const nearestItems = this.itemsIndex.getNearestTo(point5, maxItems, filter, maxDistance);
|
|
52170
|
-
|
|
52171
|
-
const combined = nearestItems.concat(nearestFrames);
|
|
52172
|
-
combined.sort((aa, bb) => {
|
|
52124
|
+
nearestItems.sort((aa, bb) => {
|
|
52173
52125
|
const distA = point5.getDistance(aa.getMbr().getCenter());
|
|
52174
52126
|
const distB = point5.getDistance(bb.getMbr().getCenter());
|
|
52175
52127
|
return distA - distB;
|
|
52176
52128
|
});
|
|
52177
|
-
return
|
|
52129
|
+
return nearestItems.slice(0, maxItems);
|
|
52178
52130
|
}
|
|
52179
52131
|
list() {
|
|
52180
52132
|
return this.itemsArray.concat();
|
|
52181
52133
|
}
|
|
52182
|
-
listFrames() {
|
|
52183
|
-
return this.framesArray.concat();
|
|
52184
|
-
}
|
|
52185
52134
|
getZIndex(item) {
|
|
52186
|
-
|
|
52187
|
-
return this.framesArray.indexOf(item);
|
|
52188
|
-
} else {
|
|
52189
|
-
return this.itemsArray.indexOf(item);
|
|
52190
|
-
}
|
|
52135
|
+
return this.itemsArray.indexOf(item);
|
|
52191
52136
|
}
|
|
52192
52137
|
getLastZIndex() {
|
|
52193
|
-
return this.itemsArray.length
|
|
52138
|
+
return this.itemsArray.length - 1;
|
|
52194
52139
|
}
|
|
52195
52140
|
getByZIndex(index2) {
|
|
52196
|
-
const totalItems = this.itemsArray.length + this.framesArray.length;
|
|
52197
52141
|
if (index2 < this.itemsArray.length) {
|
|
52198
52142
|
return this.itemsArray[index2];
|
|
52199
|
-
} else if (index2 < totalItems) {
|
|
52200
|
-
return this.framesArray[index2 - this.itemsArray.length];
|
|
52201
52143
|
} else {
|
|
52202
52144
|
const lastIndex = this.getLastZIndex();
|
|
52203
|
-
|
|
52204
|
-
return this.framesArray[lastIndex];
|
|
52205
|
-
} else {
|
|
52206
|
-
return this.itemsArray[lastIndex];
|
|
52207
|
-
}
|
|
52145
|
+
return this.itemsArray[lastIndex];
|
|
52208
52146
|
}
|
|
52209
52147
|
}
|
|
52210
52148
|
}
|
|
@@ -52227,7 +52165,10 @@ class Items {
|
|
|
52227
52165
|
return this.index.list();
|
|
52228
52166
|
}
|
|
52229
52167
|
listFrames() {
|
|
52230
|
-
return this.index.
|
|
52168
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
52169
|
+
}
|
|
52170
|
+
listGroupItems() {
|
|
52171
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
52231
52172
|
}
|
|
52232
52173
|
getById(id) {
|
|
52233
52174
|
return this.index.getById(id);
|
|
@@ -52241,8 +52182,8 @@ class Items {
|
|
|
52241
52182
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
52242
52183
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
52243
52184
|
}
|
|
52244
|
-
|
|
52245
|
-
return this.index.
|
|
52185
|
+
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
52186
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.getChildrenIds());
|
|
52246
52187
|
}
|
|
52247
52188
|
getUnderPoint(point5, tolerance = 5) {
|
|
52248
52189
|
return this.index.getUnderPoint(point5, tolerance);
|
|
@@ -52258,9 +52199,9 @@ class Items {
|
|
|
52258
52199
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
52259
52200
|
return this.index.getItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
52260
52201
|
}
|
|
52261
|
-
|
|
52202
|
+
getGroupItemsInView() {
|
|
52262
52203
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
52263
|
-
return this.
|
|
52204
|
+
return this.getGroupItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
52264
52205
|
}
|
|
52265
52206
|
getComments() {
|
|
52266
52207
|
return this.index.getComments();
|
|
@@ -52298,11 +52239,7 @@ class Items {
|
|
|
52298
52239
|
if (nearest) {
|
|
52299
52240
|
return [nearest];
|
|
52300
52241
|
}
|
|
52301
|
-
|
|
52302
|
-
if (frames.length === 0 && unmodifiedSize !== 16) {
|
|
52303
|
-
return this.getUnderPointer(16);
|
|
52304
|
-
}
|
|
52305
|
-
return frames;
|
|
52242
|
+
return [];
|
|
52306
52243
|
}
|
|
52307
52244
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
52308
52245
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
@@ -52353,41 +52290,39 @@ class Items {
|
|
|
52353
52290
|
});
|
|
52354
52291
|
}
|
|
52355
52292
|
render(context) {
|
|
52356
|
-
const
|
|
52357
|
-
|
|
52358
|
-
|
|
52359
|
-
|
|
52360
|
-
|
|
52361
|
-
frame.getChildrenIds().map((id) => this.getById(id)).forEach((child) => {
|
|
52362
|
-
if (child) {
|
|
52363
|
-
frameChildrenIds.push(child.getId());
|
|
52364
|
-
child.render(context);
|
|
52365
|
-
}
|
|
52366
|
-
});
|
|
52293
|
+
const items = this.getItemsInView();
|
|
52294
|
+
items.forEach((item) => {
|
|
52295
|
+
if (item.parent !== "Board") {
|
|
52296
|
+
item.render(context);
|
|
52297
|
+
}
|
|
52367
52298
|
});
|
|
52368
|
-
rest.filter((item) => !frameChildrenIds.includes(item.getId())).forEach((item) => item.render(context));
|
|
52369
|
-
frames.forEach((frame) => frame.renderBorders(context));
|
|
52370
|
-
frames.forEach((frame) => frame.renderName(context));
|
|
52371
52299
|
}
|
|
52372
52300
|
renderHTML(documentFactory) {
|
|
52373
|
-
const
|
|
52374
|
-
|
|
52375
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
52301
|
+
const items = this.getItemsInView();
|
|
52302
|
+
return this.getHTML(documentFactory, items);
|
|
52376
52303
|
}
|
|
52377
52304
|
getWholeHTML(documentFactory) {
|
|
52378
|
-
const
|
|
52379
|
-
|
|
52380
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
52305
|
+
const items = this.listAll();
|
|
52306
|
+
return this.getHTML(documentFactory, items);
|
|
52381
52307
|
}
|
|
52382
|
-
getHTML(documentFactory,
|
|
52383
|
-
const lowestCoordinates =
|
|
52308
|
+
getHTML(documentFactory, items) {
|
|
52309
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
52384
52310
|
left: Math.min(acc.left, mbr.left),
|
|
52385
52311
|
top: Math.min(acc.top, mbr.top)
|
|
52386
52312
|
}), { left: 0, top: 0 });
|
|
52313
|
+
const groups = [];
|
|
52314
|
+
const rest = [];
|
|
52315
|
+
items.forEach((item) => {
|
|
52316
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
52317
|
+
groups.push(item);
|
|
52318
|
+
} else {
|
|
52319
|
+
rest.push(item);
|
|
52320
|
+
}
|
|
52321
|
+
});
|
|
52387
52322
|
const childrenMap = new Map;
|
|
52388
|
-
const
|
|
52389
|
-
|
|
52390
|
-
const html4 =
|
|
52323
|
+
const GroupsHTML = groups.map((group) => {
|
|
52324
|
+
group.getChildrenIds().forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
52325
|
+
const html4 = group.renderHTML(documentFactory);
|
|
52391
52326
|
translateElementBy(html4, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
52392
52327
|
return html4;
|
|
52393
52328
|
});
|
|
@@ -52406,15 +52341,15 @@ class Items {
|
|
|
52406
52341
|
});
|
|
52407
52342
|
for (const item of restHTML) {
|
|
52408
52343
|
const parentFrameId = childrenMap.get(item.id);
|
|
52409
|
-
const
|
|
52410
|
-
if (
|
|
52411
|
-
positionRelatively(item,
|
|
52412
|
-
|
|
52344
|
+
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
52345
|
+
if (group) {
|
|
52346
|
+
positionRelatively(item, group);
|
|
52347
|
+
group.appendChild(item);
|
|
52413
52348
|
}
|
|
52414
52349
|
}
|
|
52415
52350
|
let result = "";
|
|
52416
|
-
for (const
|
|
52417
|
-
result +=
|
|
52351
|
+
for (const group of GroupsHTML) {
|
|
52352
|
+
result += group.outerHTML;
|
|
52418
52353
|
}
|
|
52419
52354
|
for (const item of restHTML) {
|
|
52420
52355
|
if (!childrenMap.get(item.id)) {
|
|
@@ -53059,24 +52994,24 @@ class Board {
|
|
|
53059
52994
|
}
|
|
53060
52995
|
handleNesting(items) {
|
|
53061
52996
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
53062
|
-
const
|
|
52997
|
+
const groupsMap = new Map;
|
|
53063
52998
|
arrayed.forEach((item) => {
|
|
53064
52999
|
const itemCenter = item.getMbr().getCenter();
|
|
53065
|
-
const
|
|
53066
|
-
if (!acc ||
|
|
53067
|
-
acc =
|
|
53000
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
53001
|
+
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
53002
|
+
acc = groupItem2;
|
|
53068
53003
|
}
|
|
53069
53004
|
return acc;
|
|
53070
53005
|
}, undefined);
|
|
53071
|
-
if (
|
|
53072
|
-
if (!
|
|
53073
|
-
|
|
53006
|
+
if (groupItem) {
|
|
53007
|
+
if (!groupsMap.has(groupItem)) {
|
|
53008
|
+
groupsMap.set(groupItem, []);
|
|
53074
53009
|
}
|
|
53075
|
-
|
|
53010
|
+
groupsMap.get(groupItem)?.push(item);
|
|
53076
53011
|
}
|
|
53077
53012
|
});
|
|
53078
|
-
|
|
53079
|
-
|
|
53013
|
+
groupsMap.forEach((items2, group) => {
|
|
53014
|
+
group.addChildItems(items2);
|
|
53080
53015
|
});
|
|
53081
53016
|
}
|
|
53082
53017
|
createItem(id, data) {
|
|
@@ -53789,7 +53724,7 @@ class Board {
|
|
|
53789
53724
|
return this.items.findById(item.getId()) !== undefined;
|
|
53790
53725
|
}
|
|
53791
53726
|
getMaxFrameSerial() {
|
|
53792
|
-
const existingNames = this.items.
|
|
53727
|
+
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
53793
53728
|
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);
|
|
53794
53729
|
}
|
|
53795
53730
|
setInterfaceType(interfaceType) {
|