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/index.js
CHANGED
|
@@ -19495,6 +19495,7 @@ class BaseItem extends Mbr {
|
|
|
19495
19495
|
children = null;
|
|
19496
19496
|
canBeNested = true;
|
|
19497
19497
|
transformationRenderBlock = undefined;
|
|
19498
|
+
childItems = null;
|
|
19498
19499
|
board;
|
|
19499
19500
|
id;
|
|
19500
19501
|
subject = new Subject;
|
|
@@ -19525,6 +19526,9 @@ class BaseItem extends Mbr {
|
|
|
19525
19526
|
this.getRichText()?.setId(id);
|
|
19526
19527
|
return this;
|
|
19527
19528
|
}
|
|
19529
|
+
getChildrenIds() {
|
|
19530
|
+
return this.children;
|
|
19531
|
+
}
|
|
19528
19532
|
addChildItems(children) {
|
|
19529
19533
|
if (!this.children) {
|
|
19530
19534
|
return;
|
|
@@ -19591,15 +19595,20 @@ class BaseItem extends Mbr {
|
|
|
19591
19595
|
if (!this.children) {
|
|
19592
19596
|
return;
|
|
19593
19597
|
}
|
|
19594
|
-
|
|
19595
|
-
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
+
const updatedChildItems = [];
|
|
19599
|
+
children.forEach((childId) => {
|
|
19600
|
+
const foundItem = this.board.items.getById(childId);
|
|
19601
|
+
if (foundItem) {
|
|
19602
|
+
updatedChildItems.push(foundItem);
|
|
19603
|
+
}
|
|
19604
|
+
if (this.parent !== childId && this.getId() !== childId) {
|
|
19605
|
+
if (!this.children.includes(childId) && foundItem) {
|
|
19598
19606
|
foundItem.parent = this.getId();
|
|
19599
19607
|
}
|
|
19600
19608
|
}
|
|
19601
19609
|
});
|
|
19602
19610
|
this.children = children;
|
|
19611
|
+
this.childItems = updatedChildItems;
|
|
19603
19612
|
this.updateMbr();
|
|
19604
19613
|
this.subject.publish(this);
|
|
19605
19614
|
}
|
|
@@ -19675,7 +19684,13 @@ class BaseItem extends Mbr {
|
|
|
19675
19684
|
getPath() {
|
|
19676
19685
|
return new Path(this.getMbr().getLines());
|
|
19677
19686
|
}
|
|
19678
|
-
render(context) {
|
|
19687
|
+
render(context) {
|
|
19688
|
+
if (this.childItems) {
|
|
19689
|
+
this.childItems.forEach((child) => {
|
|
19690
|
+
child.render(context);
|
|
19691
|
+
});
|
|
19692
|
+
}
|
|
19693
|
+
}
|
|
19679
19694
|
renderHTML(documentFactory) {
|
|
19680
19695
|
return documentFactory.createElement("div");
|
|
19681
19696
|
}
|
|
@@ -38704,8 +38719,10 @@ class Frame extends BaseItem {
|
|
|
38704
38719
|
if (this.transformationRenderBlock) {
|
|
38705
38720
|
return;
|
|
38706
38721
|
}
|
|
38707
|
-
this.
|
|
38708
|
-
|
|
38722
|
+
this.renderPath(context);
|
|
38723
|
+
super.render(context);
|
|
38724
|
+
this.renderBorders(context);
|
|
38725
|
+
this.renderName(context);
|
|
38709
38726
|
}
|
|
38710
38727
|
renderName(context) {
|
|
38711
38728
|
if (this.transformationRenderBlock) {
|
|
@@ -41821,8 +41838,8 @@ class NestingHighlighter extends Tool {
|
|
|
41821
41838
|
listAll() {
|
|
41822
41839
|
return this.toHighlight;
|
|
41823
41840
|
}
|
|
41824
|
-
add(
|
|
41825
|
-
const existing = this.toHighlight.find((group) => group.
|
|
41841
|
+
add(groupItem, children) {
|
|
41842
|
+
const existing = this.toHighlight.find((group) => group.groupItem === groupItem);
|
|
41826
41843
|
const array = Array.isArray(children) ? children : [children];
|
|
41827
41844
|
if (existing) {
|
|
41828
41845
|
array.forEach((child) => {
|
|
@@ -41831,7 +41848,7 @@ class NestingHighlighter extends Tool {
|
|
|
41831
41848
|
}
|
|
41832
41849
|
});
|
|
41833
41850
|
} else {
|
|
41834
|
-
this.toHighlight.push({
|
|
41851
|
+
this.toHighlight.push({ groupItem, children: array });
|
|
41835
41852
|
}
|
|
41836
41853
|
}
|
|
41837
41854
|
addSingleItem(item) {
|
|
@@ -41846,8 +41863,8 @@ class NestingHighlighter extends Tool {
|
|
|
41846
41863
|
render(context) {
|
|
41847
41864
|
if (this.toHighlight.length > 0) {
|
|
41848
41865
|
this.toHighlight.forEach((group) => {
|
|
41849
|
-
if (group.
|
|
41850
|
-
const frameRect = group.
|
|
41866
|
+
if (group.groupItem) {
|
|
41867
|
+
const frameRect = group.groupItem.getMbr();
|
|
41851
41868
|
frameRect.borderColor = FRAME_HIGHLIGHTER_BORDER_COLOR;
|
|
41852
41869
|
frameRect.strokeWidth = 0.3;
|
|
41853
41870
|
frameRect.render(context);
|
|
@@ -41942,7 +41959,7 @@ class AddFrame extends BoardTool {
|
|
|
41942
41959
|
return true;
|
|
41943
41960
|
}
|
|
41944
41961
|
addNextTo() {
|
|
41945
|
-
const framesInView = this.board.items.
|
|
41962
|
+
const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame);
|
|
41946
41963
|
if (framesInView.length === 0) {
|
|
41947
41964
|
if (this.shape === "Custom") {
|
|
41948
41965
|
const { x, y } = this.frame.getLastFrameScale();
|
|
@@ -41954,7 +41971,7 @@ class AddFrame extends BoardTool {
|
|
|
41954
41971
|
}
|
|
41955
41972
|
this.transformToCenter();
|
|
41956
41973
|
} else {
|
|
41957
|
-
const frames = this.board.items.
|
|
41974
|
+
const frames = this.board.items.listAll().filter((frame2) => frame2 instanceof Frame && frame2 !== this.frame);
|
|
41958
41975
|
let nextTo = framesInView.reduce((rightest, frame2) => {
|
|
41959
41976
|
if (frame2.getMbr().right > rightest.getMbr().right) {
|
|
41960
41977
|
rightest = frame2;
|
|
@@ -43132,17 +43149,17 @@ function createCanvasDrawer(board) {
|
|
|
43132
43149
|
const realRight = realLeft + adjustedWidth;
|
|
43133
43150
|
const realBottom = realTop + adjustedHeight;
|
|
43134
43151
|
const containerMbr = new Mbr(realLeft, realTop, realRight, realBottom);
|
|
43135
|
-
const
|
|
43136
|
-
if (
|
|
43152
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(containerMbr.left, containerMbr.top, containerMbr.right, containerMbr.bottom);
|
|
43153
|
+
if (groups) {
|
|
43137
43154
|
drawnItemsMap?.forEach(({ mbr }) => {
|
|
43138
43155
|
mbr.transform(currMatrix);
|
|
43139
43156
|
});
|
|
43140
|
-
|
|
43157
|
+
groups.forEach((group) => {
|
|
43141
43158
|
drawnItemsMap?.forEach(({ mbr, item }, key) => {
|
|
43142
|
-
if (item
|
|
43159
|
+
if ("canBeNested" in item && !item.canBeNested) {
|
|
43143
43160
|
return;
|
|
43144
43161
|
}
|
|
43145
|
-
if (lastCreatedCanvas && (!drawnItemsMap.get(
|
|
43162
|
+
if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
|
|
43146
43163
|
const div = createBorderDivForItem(mbr, lastCreatedCanvas);
|
|
43147
43164
|
removeHighlighted(key);
|
|
43148
43165
|
highlightedDivs.set(key, div);
|
|
@@ -45231,7 +45248,7 @@ class Tools extends ToolContext {
|
|
|
45231
45248
|
this.subject.publish(this);
|
|
45232
45249
|
}
|
|
45233
45250
|
sortFrames() {
|
|
45234
|
-
const frames = this.board.items.
|
|
45251
|
+
const frames = this.board.items.listAll().filter((item) => item instanceof Frame);
|
|
45235
45252
|
const sortedFrames = frames.sort((fr1, fr2) => {
|
|
45236
45253
|
const mbr1 = fr1.getMbr();
|
|
45237
45254
|
const mbr2 = fr2.getMbr();
|
|
@@ -49318,9 +49335,9 @@ function updateFrameChildren({
|
|
|
49318
49335
|
board,
|
|
49319
49336
|
nestingHighlighter
|
|
49320
49337
|
}) {
|
|
49321
|
-
const
|
|
49338
|
+
const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
|
|
49322
49339
|
board.selection.items.list().forEach((item) => {
|
|
49323
|
-
if (item
|
|
49340
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
49324
49341
|
const currMbr = item.getMbr();
|
|
49325
49342
|
const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
|
|
49326
49343
|
itemsToCheck.forEach((currItem) => {
|
|
@@ -49331,9 +49348,9 @@ function updateFrameChildren({
|
|
|
49331
49348
|
}
|
|
49332
49349
|
});
|
|
49333
49350
|
} else {
|
|
49334
|
-
|
|
49335
|
-
if (
|
|
49336
|
-
nestingHighlighter.add(
|
|
49351
|
+
groups.forEach((group) => {
|
|
49352
|
+
if (group.handleNesting(item)) {
|
|
49353
|
+
nestingHighlighter.add(group, item);
|
|
49337
49354
|
} else {
|
|
49338
49355
|
nestingHighlighter.remove(item);
|
|
49339
49356
|
}
|
|
@@ -49852,9 +49869,7 @@ class BoardSelection {
|
|
|
49852
49869
|
}
|
|
49853
49870
|
addAll() {
|
|
49854
49871
|
const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
|
|
49855
|
-
const frames = this.board.items.listFrames().filter((item) => !item.transformation.isLocked);
|
|
49856
49872
|
this.add(items);
|
|
49857
|
-
this.add(frames);
|
|
49858
49873
|
this.setContext("SelectByRect");
|
|
49859
49874
|
}
|
|
49860
49875
|
remove(value) {
|
|
@@ -50283,38 +50298,38 @@ class BoardSelection {
|
|
|
50283
50298
|
}, undefined);
|
|
50284
50299
|
if (selectedMbr) {
|
|
50285
50300
|
const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
|
|
50286
|
-
const
|
|
50287
|
-
|
|
50301
|
+
const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
|
|
50302
|
+
enclosedGroups.forEach((group) => {
|
|
50288
50303
|
selected.forEach((item) => {
|
|
50289
|
-
if (
|
|
50290
|
-
selectedMap[item.getId()].nested =
|
|
50304
|
+
if (group.handleNesting(item)) {
|
|
50305
|
+
selectedMap[item.getId()].nested = group;
|
|
50291
50306
|
}
|
|
50292
50307
|
});
|
|
50293
50308
|
});
|
|
50294
50309
|
Object.values(selectedMap).forEach((val) => {
|
|
50295
|
-
const
|
|
50296
|
-
const
|
|
50297
|
-
const parentFrameId = isParentFrame ? parentFrame.getId() : null;
|
|
50310
|
+
const parentGroup = this.board.items.getById(val.item.parent);
|
|
50311
|
+
const parentGroupId = parentGroup?.getId();
|
|
50298
50312
|
if (val.nested) {
|
|
50299
|
-
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !==
|
|
50300
|
-
if (
|
|
50301
|
-
|
|
50313
|
+
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentGroupId);
|
|
50314
|
+
if (parentGroupId && isRemoveChildFromFrame) {
|
|
50315
|
+
parentGroup?.removeChildItems([val.item]);
|
|
50302
50316
|
}
|
|
50303
50317
|
val.nested.addChildItems([val.item]);
|
|
50304
50318
|
} else if (val.item.parent !== "Board") {
|
|
50305
|
-
if (
|
|
50306
|
-
|
|
50319
|
+
if (parentGroupId) {
|
|
50320
|
+
parentGroup?.removeChildItems([val.item]);
|
|
50307
50321
|
} else {
|
|
50308
50322
|
console.warn(`Didnt find frame with id ${val.item.parent}`);
|
|
50309
50323
|
}
|
|
50310
50324
|
}
|
|
50311
|
-
|
|
50312
|
-
|
|
50313
|
-
const
|
|
50314
|
-
const
|
|
50315
|
-
const
|
|
50325
|
+
const childrenIds = val.item.getChildrenIds();
|
|
50326
|
+
if (childrenIds && checkFrames) {
|
|
50327
|
+
const currGroup = val.item;
|
|
50328
|
+
const currMbr = currGroup.getMbr();
|
|
50329
|
+
const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
50330
|
+
const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
|
|
50316
50331
|
const uniqueItems = new Set;
|
|
50317
|
-
const toCheck = [...children, ...
|
|
50332
|
+
const toCheck = [...children, ...underGroup].filter((item) => {
|
|
50318
50333
|
const id = item.getId();
|
|
50319
50334
|
if (uniqueItems.has(id)) {
|
|
50320
50335
|
return false;
|
|
@@ -50322,7 +50337,7 @@ class BoardSelection {
|
|
|
50322
50337
|
uniqueItems.add(id);
|
|
50323
50338
|
return true;
|
|
50324
50339
|
});
|
|
50325
|
-
|
|
50340
|
+
currGroup.emitNesting(toCheck);
|
|
50326
50341
|
}
|
|
50327
50342
|
});
|
|
50328
50343
|
}
|
|
@@ -51932,13 +51947,9 @@ class LayeredIndex {
|
|
|
51932
51947
|
class SpatialIndex {
|
|
51933
51948
|
subject = new Subject;
|
|
51934
51949
|
itemsArray = [];
|
|
51935
|
-
framesArray = [];
|
|
51936
51950
|
itemsIndex = new LayeredIndex((item) => {
|
|
51937
51951
|
return this.itemsArray.indexOf(item);
|
|
51938
51952
|
});
|
|
51939
|
-
framesIndex = new LayeredIndex((item) => {
|
|
51940
|
-
return this.framesArray.indexOf(item);
|
|
51941
|
-
});
|
|
51942
51953
|
Mbr = new Mbr;
|
|
51943
51954
|
items;
|
|
51944
51955
|
constructor(view, pointer) {
|
|
@@ -51946,23 +51957,14 @@ class SpatialIndex {
|
|
|
51946
51957
|
}
|
|
51947
51958
|
clear() {
|
|
51948
51959
|
this.itemsArray = [];
|
|
51949
|
-
this.framesArray = [];
|
|
51950
51960
|
this.itemsIndex = new LayeredIndex((item) => {
|
|
51951
51961
|
return this.itemsArray.indexOf(item);
|
|
51952
51962
|
});
|
|
51953
|
-
this.framesIndex = new LayeredIndex((item) => {
|
|
51954
|
-
return this.framesArray.indexOf(item);
|
|
51955
|
-
});
|
|
51956
51963
|
this.Mbr = new Mbr;
|
|
51957
51964
|
}
|
|
51958
51965
|
insert(item) {
|
|
51959
|
-
|
|
51960
|
-
|
|
51961
|
-
this.framesIndex.insert(item);
|
|
51962
|
-
} else {
|
|
51963
|
-
this.itemsArray.push(item);
|
|
51964
|
-
this.itemsIndex.insert(item);
|
|
51965
|
-
}
|
|
51966
|
+
this.itemsArray.push(item);
|
|
51967
|
+
this.itemsIndex.insert(item);
|
|
51966
51968
|
if (conf.isNode()) {
|
|
51967
51969
|
return;
|
|
51968
51970
|
}
|
|
@@ -51975,11 +51977,7 @@ class SpatialIndex {
|
|
|
51975
51977
|
this.subject.publish(this.items);
|
|
51976
51978
|
}
|
|
51977
51979
|
change = (item) => {
|
|
51978
|
-
|
|
51979
|
-
this.framesIndex.change(item);
|
|
51980
|
-
} else {
|
|
51981
|
-
this.itemsIndex.change(item);
|
|
51982
|
-
}
|
|
51980
|
+
this.itemsIndex.change(item);
|
|
51983
51981
|
if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
|
|
51984
51982
|
this.Mbr = item.getMbr().copy();
|
|
51985
51983
|
} else {
|
|
@@ -51996,39 +51994,22 @@ class SpatialIndex {
|
|
|
51996
51994
|
const parentFrame = this.items.getById(item.parent);
|
|
51997
51995
|
parentFrame?.removeChildItems(item);
|
|
51998
51996
|
}
|
|
51999
|
-
|
|
52000
|
-
|
|
52001
|
-
this.framesIndex.remove(item);
|
|
52002
|
-
} else {
|
|
52003
|
-
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
52004
|
-
this.itemsIndex.remove(item);
|
|
52005
|
-
}
|
|
51997
|
+
this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
|
|
51998
|
+
this.itemsIndex.remove(item);
|
|
52006
51999
|
this.Mbr = new Mbr;
|
|
52007
|
-
|
|
52008
|
-
allItems.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
52000
|
+
this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
|
|
52009
52001
|
this.subject.publish(this.items);
|
|
52010
52002
|
}
|
|
52011
52003
|
copy() {
|
|
52012
|
-
|
|
52004
|
+
return this.itemsArray.map((item) => ({
|
|
52013
52005
|
...item.serialize(true),
|
|
52014
52006
|
id: item.getId()
|
|
52015
52007
|
}));
|
|
52016
|
-
const framesData = this.framesArray.map((item) => ({
|
|
52017
|
-
...item.serialize(),
|
|
52018
|
-
id: item.getId()
|
|
52019
|
-
}));
|
|
52020
|
-
return [...framesData, ...itemsData];
|
|
52021
52008
|
}
|
|
52022
52009
|
moveToZIndex(item, zIndex) {
|
|
52023
|
-
|
|
52024
|
-
|
|
52025
|
-
|
|
52026
|
-
this.framesArray.splice(zIndex, 0, item);
|
|
52027
|
-
} else {
|
|
52028
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
52029
|
-
this.itemsArray.splice(index2, 1);
|
|
52030
|
-
this.itemsArray.splice(zIndex, 0, item);
|
|
52031
|
-
}
|
|
52010
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
52011
|
+
this.itemsArray.splice(index2, 1);
|
|
52012
|
+
this.itemsArray.splice(zIndex, 0, item);
|
|
52032
52013
|
this.change(item);
|
|
52033
52014
|
this.subject.publish(this.items);
|
|
52034
52015
|
}
|
|
@@ -52042,17 +52023,10 @@ class SpatialIndex {
|
|
|
52042
52023
|
this.itemsArray.forEach(this.change.bind(this));
|
|
52043
52024
|
}
|
|
52044
52025
|
sendToBack(item, shouldPublish = true) {
|
|
52045
|
-
|
|
52046
|
-
|
|
52047
|
-
|
|
52048
|
-
|
|
52049
|
-
this.framesIndex.change(item);
|
|
52050
|
-
} else {
|
|
52051
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
52052
|
-
this.itemsArray.splice(index2, 1);
|
|
52053
|
-
this.itemsArray.unshift(item);
|
|
52054
|
-
this.itemsIndex.change(item);
|
|
52055
|
-
}
|
|
52026
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
52027
|
+
this.itemsArray.splice(index2, 1);
|
|
52028
|
+
this.itemsArray.unshift(item);
|
|
52029
|
+
this.itemsIndex.change(item);
|
|
52056
52030
|
if (shouldPublish) {
|
|
52057
52031
|
this.subject.publish(this.items);
|
|
52058
52032
|
}
|
|
@@ -52068,17 +52042,10 @@ class SpatialIndex {
|
|
|
52068
52042
|
this.itemsArray.forEach(this.change.bind(this));
|
|
52069
52043
|
}
|
|
52070
52044
|
bringToFront(item, shouldPublish = true) {
|
|
52071
|
-
|
|
52072
|
-
|
|
52073
|
-
|
|
52074
|
-
|
|
52075
|
-
this.framesIndex.change(item);
|
|
52076
|
-
} else {
|
|
52077
|
-
const index2 = this.itemsArray.indexOf(item);
|
|
52078
|
-
this.itemsArray.splice(index2, 1);
|
|
52079
|
-
this.itemsArray.push(item);
|
|
52080
|
-
this.itemsIndex.change(item);
|
|
52081
|
-
}
|
|
52045
|
+
const index2 = this.itemsArray.indexOf(item);
|
|
52046
|
+
this.itemsArray.splice(index2, 1);
|
|
52047
|
+
this.itemsArray.push(item);
|
|
52048
|
+
this.itemsIndex.change(item);
|
|
52082
52049
|
if (shouldPublish) {
|
|
52083
52050
|
this.subject.publish(this.items);
|
|
52084
52051
|
}
|
|
@@ -52117,37 +52084,24 @@ class SpatialIndex {
|
|
|
52117
52084
|
if (item) {
|
|
52118
52085
|
return item;
|
|
52119
52086
|
}
|
|
52120
|
-
const frame = this.framesArray.find((frame2) => frame2.getId() === id);
|
|
52121
|
-
return frame;
|
|
52122
52087
|
}
|
|
52123
52088
|
findById(id) {
|
|
52124
52089
|
return this.getById(id);
|
|
52125
52090
|
}
|
|
52126
52091
|
getEnclosed(left, top, right, bottom) {
|
|
52127
52092
|
const mbr = new Mbr(left, top, right, bottom);
|
|
52128
|
-
|
|
52129
|
-
const enclosedFrames = this.framesIndex.getEnclosed(mbr);
|
|
52130
|
-
return enclosedFrames.concat(enclosedItems);
|
|
52093
|
+
return this.itemsIndex.getEnclosed(mbr);
|
|
52131
52094
|
}
|
|
52132
52095
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
52133
52096
|
const mbr = new Mbr(left, top, right, bottom);
|
|
52134
|
-
|
|
52135
|
-
const enclosedOrCrossedFrames = this.framesIndex.getEnclosedOrCrossedBy(mbr);
|
|
52136
|
-
return enclosedOrCrossedFrames.concat(enclosedOrCrossedItems);
|
|
52097
|
+
return this.itemsIndex.getEnclosedOrCrossedBy(mbr);
|
|
52137
52098
|
}
|
|
52138
52099
|
getUnderPoint(point5, tolerace = 5) {
|
|
52139
|
-
|
|
52140
|
-
const framesUnderPoint = this.framesIndex.getUnderPoint(point5, tolerace);
|
|
52141
|
-
return [...framesUnderPoint, ...itemsUnderPoint];
|
|
52100
|
+
return this.itemsIndex.getUnderPoint(point5, tolerace);
|
|
52142
52101
|
}
|
|
52143
52102
|
getRectsEnclosedOrCrossed(left, top, right, bottom) {
|
|
52144
52103
|
const mbr = new Mbr(left, top, right, bottom);
|
|
52145
|
-
|
|
52146
|
-
const woFrames = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
52147
|
-
return [...woFrames, ...frames];
|
|
52148
|
-
}
|
|
52149
|
-
getFramesEnclosedOrCrossed(left, top, right, bottom) {
|
|
52150
|
-
return this.framesIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
52104
|
+
return this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
|
|
52151
52105
|
}
|
|
52152
52106
|
getItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
52153
52107
|
return this.itemsIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
@@ -52160,44 +52114,28 @@ class SpatialIndex {
|
|
|
52160
52114
|
}
|
|
52161
52115
|
getNearestTo(point5, maxItems, filter, maxDistance) {
|
|
52162
52116
|
const nearestItems = this.itemsIndex.getNearestTo(point5, maxItems, filter, maxDistance);
|
|
52163
|
-
|
|
52164
|
-
const combined = nearestItems.concat(nearestFrames);
|
|
52165
|
-
combined.sort((aa, bb) => {
|
|
52117
|
+
nearestItems.sort((aa, bb) => {
|
|
52166
52118
|
const distA = point5.getDistance(aa.getMbr().getCenter());
|
|
52167
52119
|
const distB = point5.getDistance(bb.getMbr().getCenter());
|
|
52168
52120
|
return distA - distB;
|
|
52169
52121
|
});
|
|
52170
|
-
return
|
|
52122
|
+
return nearestItems.slice(0, maxItems);
|
|
52171
52123
|
}
|
|
52172
52124
|
list() {
|
|
52173
52125
|
return this.itemsArray.concat();
|
|
52174
52126
|
}
|
|
52175
|
-
listFrames() {
|
|
52176
|
-
return this.framesArray.concat();
|
|
52177
|
-
}
|
|
52178
52127
|
getZIndex(item) {
|
|
52179
|
-
|
|
52180
|
-
return this.framesArray.indexOf(item);
|
|
52181
|
-
} else {
|
|
52182
|
-
return this.itemsArray.indexOf(item);
|
|
52183
|
-
}
|
|
52128
|
+
return this.itemsArray.indexOf(item);
|
|
52184
52129
|
}
|
|
52185
52130
|
getLastZIndex() {
|
|
52186
|
-
return this.itemsArray.length
|
|
52131
|
+
return this.itemsArray.length - 1;
|
|
52187
52132
|
}
|
|
52188
52133
|
getByZIndex(index2) {
|
|
52189
|
-
const totalItems = this.itemsArray.length + this.framesArray.length;
|
|
52190
52134
|
if (index2 < this.itemsArray.length) {
|
|
52191
52135
|
return this.itemsArray[index2];
|
|
52192
|
-
} else if (index2 < totalItems) {
|
|
52193
|
-
return this.framesArray[index2 - this.itemsArray.length];
|
|
52194
52136
|
} else {
|
|
52195
52137
|
const lastIndex = this.getLastZIndex();
|
|
52196
|
-
|
|
52197
|
-
return this.framesArray[lastIndex];
|
|
52198
|
-
} else {
|
|
52199
|
-
return this.itemsArray[lastIndex];
|
|
52200
|
-
}
|
|
52138
|
+
return this.itemsArray[lastIndex];
|
|
52201
52139
|
}
|
|
52202
52140
|
}
|
|
52203
52141
|
}
|
|
@@ -52220,7 +52158,10 @@ class Items {
|
|
|
52220
52158
|
return this.index.list();
|
|
52221
52159
|
}
|
|
52222
52160
|
listFrames() {
|
|
52223
|
-
return this.index.
|
|
52161
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
52162
|
+
}
|
|
52163
|
+
listGroupItems() {
|
|
52164
|
+
return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
|
|
52224
52165
|
}
|
|
52225
52166
|
getById(id) {
|
|
52226
52167
|
return this.index.getById(id);
|
|
@@ -52234,8 +52175,8 @@ class Items {
|
|
|
52234
52175
|
getEnclosedOrCrossed(left, top, right, bottom) {
|
|
52235
52176
|
return this.index.getEnclosedOrCrossed(left, top, right, bottom);
|
|
52236
52177
|
}
|
|
52237
|
-
|
|
52238
|
-
return this.index.
|
|
52178
|
+
getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
|
|
52179
|
+
return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.getChildrenIds());
|
|
52239
52180
|
}
|
|
52240
52181
|
getUnderPoint(point5, tolerance = 5) {
|
|
52241
52182
|
return this.index.getUnderPoint(point5, tolerance);
|
|
@@ -52251,9 +52192,9 @@ class Items {
|
|
|
52251
52192
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
52252
52193
|
return this.index.getItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
52253
52194
|
}
|
|
52254
|
-
|
|
52195
|
+
getGroupItemsInView() {
|
|
52255
52196
|
const { left, top, right, bottom } = this.view.getMbr();
|
|
52256
|
-
return this.
|
|
52197
|
+
return this.getGroupItemsEnclosedOrCrossed(left, top, right, bottom);
|
|
52257
52198
|
}
|
|
52258
52199
|
getComments() {
|
|
52259
52200
|
return this.index.getComments();
|
|
@@ -52291,11 +52232,7 @@ class Items {
|
|
|
52291
52232
|
if (nearest) {
|
|
52292
52233
|
return [nearest];
|
|
52293
52234
|
}
|
|
52294
|
-
|
|
52295
|
-
if (frames.length === 0 && unmodifiedSize !== 16) {
|
|
52296
|
-
return this.getUnderPointer(16);
|
|
52297
|
-
}
|
|
52298
|
-
return frames;
|
|
52235
|
+
return [];
|
|
52299
52236
|
}
|
|
52300
52237
|
getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
|
|
52301
52238
|
return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
|
|
@@ -52346,41 +52283,39 @@ class Items {
|
|
|
52346
52283
|
});
|
|
52347
52284
|
}
|
|
52348
52285
|
render(context) {
|
|
52349
|
-
const
|
|
52350
|
-
|
|
52351
|
-
|
|
52352
|
-
|
|
52353
|
-
|
|
52354
|
-
frame.getChildrenIds().map((id) => this.getById(id)).forEach((child) => {
|
|
52355
|
-
if (child) {
|
|
52356
|
-
frameChildrenIds.push(child.getId());
|
|
52357
|
-
child.render(context);
|
|
52358
|
-
}
|
|
52359
|
-
});
|
|
52286
|
+
const items = this.getItemsInView();
|
|
52287
|
+
items.forEach((item) => {
|
|
52288
|
+
if (item.parent !== "Board") {
|
|
52289
|
+
item.render(context);
|
|
52290
|
+
}
|
|
52360
52291
|
});
|
|
52361
|
-
rest.filter((item) => !frameChildrenIds.includes(item.getId())).forEach((item) => item.render(context));
|
|
52362
|
-
frames.forEach((frame) => frame.renderBorders(context));
|
|
52363
|
-
frames.forEach((frame) => frame.renderName(context));
|
|
52364
52292
|
}
|
|
52365
52293
|
renderHTML(documentFactory) {
|
|
52366
|
-
const
|
|
52367
|
-
|
|
52368
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
52294
|
+
const items = this.getItemsInView();
|
|
52295
|
+
return this.getHTML(documentFactory, items);
|
|
52369
52296
|
}
|
|
52370
52297
|
getWholeHTML(documentFactory) {
|
|
52371
|
-
const
|
|
52372
|
-
|
|
52373
|
-
return this.getHTML(documentFactory, frames, rest);
|
|
52298
|
+
const items = this.listAll();
|
|
52299
|
+
return this.getHTML(documentFactory, items);
|
|
52374
52300
|
}
|
|
52375
|
-
getHTML(documentFactory,
|
|
52376
|
-
const lowestCoordinates =
|
|
52301
|
+
getHTML(documentFactory, items) {
|
|
52302
|
+
const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
|
|
52377
52303
|
left: Math.min(acc.left, mbr.left),
|
|
52378
52304
|
top: Math.min(acc.top, mbr.top)
|
|
52379
52305
|
}), { left: 0, top: 0 });
|
|
52306
|
+
const groups = [];
|
|
52307
|
+
const rest = [];
|
|
52308
|
+
items.forEach((item) => {
|
|
52309
|
+
if ("getChildrenIds" in item && item.getChildrenIds()) {
|
|
52310
|
+
groups.push(item);
|
|
52311
|
+
} else {
|
|
52312
|
+
rest.push(item);
|
|
52313
|
+
}
|
|
52314
|
+
});
|
|
52380
52315
|
const childrenMap = new Map;
|
|
52381
|
-
const
|
|
52382
|
-
|
|
52383
|
-
const html4 =
|
|
52316
|
+
const GroupsHTML = groups.map((group) => {
|
|
52317
|
+
group.getChildrenIds().forEach((childId) => childrenMap.set(childId, group.getId()));
|
|
52318
|
+
const html4 = group.renderHTML(documentFactory);
|
|
52384
52319
|
translateElementBy(html4, -lowestCoordinates.left, -lowestCoordinates.top);
|
|
52385
52320
|
return html4;
|
|
52386
52321
|
});
|
|
@@ -52399,15 +52334,15 @@ class Items {
|
|
|
52399
52334
|
});
|
|
52400
52335
|
for (const item of restHTML) {
|
|
52401
52336
|
const parentFrameId = childrenMap.get(item.id);
|
|
52402
|
-
const
|
|
52403
|
-
if (
|
|
52404
|
-
positionRelatively(item,
|
|
52405
|
-
|
|
52337
|
+
const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
|
|
52338
|
+
if (group) {
|
|
52339
|
+
positionRelatively(item, group);
|
|
52340
|
+
group.appendChild(item);
|
|
52406
52341
|
}
|
|
52407
52342
|
}
|
|
52408
52343
|
let result = "";
|
|
52409
|
-
for (const
|
|
52410
|
-
result +=
|
|
52344
|
+
for (const group of GroupsHTML) {
|
|
52345
|
+
result += group.outerHTML;
|
|
52411
52346
|
}
|
|
52412
52347
|
for (const item of restHTML) {
|
|
52413
52348
|
if (!childrenMap.get(item.id)) {
|
|
@@ -53052,24 +52987,24 @@ class Board {
|
|
|
53052
52987
|
}
|
|
53053
52988
|
handleNesting(items) {
|
|
53054
52989
|
const arrayed = Array.isArray(items) ? items : [items];
|
|
53055
|
-
const
|
|
52990
|
+
const groupsMap = new Map;
|
|
53056
52991
|
arrayed.forEach((item) => {
|
|
53057
52992
|
const itemCenter = item.getMbr().getCenter();
|
|
53058
|
-
const
|
|
53059
|
-
if (!acc ||
|
|
53060
|
-
acc =
|
|
52993
|
+
const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
|
|
52994
|
+
if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
|
|
52995
|
+
acc = groupItem2;
|
|
53061
52996
|
}
|
|
53062
52997
|
return acc;
|
|
53063
52998
|
}, undefined);
|
|
53064
|
-
if (
|
|
53065
|
-
if (!
|
|
53066
|
-
|
|
52999
|
+
if (groupItem) {
|
|
53000
|
+
if (!groupsMap.has(groupItem)) {
|
|
53001
|
+
groupsMap.set(groupItem, []);
|
|
53067
53002
|
}
|
|
53068
|
-
|
|
53003
|
+
groupsMap.get(groupItem)?.push(item);
|
|
53069
53004
|
}
|
|
53070
53005
|
});
|
|
53071
|
-
|
|
53072
|
-
|
|
53006
|
+
groupsMap.forEach((items2, group) => {
|
|
53007
|
+
group.addChildItems(items2);
|
|
53073
53008
|
});
|
|
53074
53009
|
}
|
|
53075
53010
|
createItem(id, data) {
|
|
@@ -53782,7 +53717,7 @@ class Board {
|
|
|
53782
53717
|
return this.items.findById(item.getId()) !== undefined;
|
|
53783
53718
|
}
|
|
53784
53719
|
getMaxFrameSerial() {
|
|
53785
|
-
const existingNames = this.items.
|
|
53720
|
+
const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
|
|
53786
53721
|
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);
|
|
53787
53722
|
}
|
|
53788
53723
|
setInterfaceType(interfaceType) {
|