microboard-temp 0.4.36 → 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.
@@ -19652,6 +19652,7 @@ class BaseItem extends Mbr {
19652
19652
  children = null;
19653
19653
  canBeNested = true;
19654
19654
  transformationRenderBlock = undefined;
19655
+ childItems = null;
19655
19656
  board;
19656
19657
  id;
19657
19658
  subject = new Subject;
@@ -19682,6 +19683,9 @@ class BaseItem extends Mbr {
19682
19683
  this.getRichText()?.setId(id);
19683
19684
  return this;
19684
19685
  }
19686
+ getChildrenIds() {
19687
+ return this.children;
19688
+ }
19685
19689
  addChildItems(children) {
19686
19690
  if (!this.children) {
19687
19691
  return;
@@ -19748,15 +19752,20 @@ class BaseItem extends Mbr {
19748
19752
  if (!this.children) {
19749
19753
  return;
19750
19754
  }
19751
- children.forEach((child) => {
19752
- if (this.parent !== child && this.getId() !== child) {
19753
- const foundItem = this.board.items.getById(child);
19754
- if (!this.children.includes(child) && foundItem) {
19755
+ const updatedChildItems = [];
19756
+ children.forEach((childId) => {
19757
+ const foundItem = this.board.items.getById(childId);
19758
+ if (foundItem) {
19759
+ updatedChildItems.push(foundItem);
19760
+ }
19761
+ if (this.parent !== childId && this.getId() !== childId) {
19762
+ if (!this.children.includes(childId) && foundItem) {
19755
19763
  foundItem.parent = this.getId();
19756
19764
  }
19757
19765
  }
19758
19766
  });
19759
19767
  this.children = children;
19768
+ this.childItems = updatedChildItems;
19760
19769
  this.updateMbr();
19761
19770
  this.subject.publish(this);
19762
19771
  }
@@ -19832,7 +19841,13 @@ class BaseItem extends Mbr {
19832
19841
  getPath() {
19833
19842
  return new Path(this.getMbr().getLines());
19834
19843
  }
19835
- render(context) {}
19844
+ render(context) {
19845
+ if (this.childItems) {
19846
+ this.childItems.forEach((child) => {
19847
+ child.render(context);
19848
+ });
19849
+ }
19850
+ }
19836
19851
  renderHTML(documentFactory) {
19837
19852
  return documentFactory.createElement("div");
19838
19853
  }
@@ -38861,8 +38876,10 @@ class Frame extends BaseItem {
38861
38876
  if (this.transformationRenderBlock) {
38862
38877
  return;
38863
38878
  }
38864
- this.path.render(context);
38865
- this.text.render(context);
38879
+ this.renderPath(context);
38880
+ super.render(context);
38881
+ this.renderBorders(context);
38882
+ this.renderName(context);
38866
38883
  }
38867
38884
  renderName(context) {
38868
38885
  if (this.transformationRenderBlock) {
@@ -41978,8 +41995,8 @@ class NestingHighlighter extends Tool {
41978
41995
  listAll() {
41979
41996
  return this.toHighlight;
41980
41997
  }
41981
- add(frame, children) {
41982
- const existing = this.toHighlight.find((group) => group.frame === frame);
41998
+ add(groupItem, children) {
41999
+ const existing = this.toHighlight.find((group) => group.groupItem === groupItem);
41983
42000
  const array = Array.isArray(children) ? children : [children];
41984
42001
  if (existing) {
41985
42002
  array.forEach((child) => {
@@ -41988,7 +42005,7 @@ class NestingHighlighter extends Tool {
41988
42005
  }
41989
42006
  });
41990
42007
  } else {
41991
- this.toHighlight.push({ frame, children: array });
42008
+ this.toHighlight.push({ groupItem, children: array });
41992
42009
  }
41993
42010
  }
41994
42011
  addSingleItem(item) {
@@ -42003,8 +42020,8 @@ class NestingHighlighter extends Tool {
42003
42020
  render(context) {
42004
42021
  if (this.toHighlight.length > 0) {
42005
42022
  this.toHighlight.forEach((group) => {
42006
- if (group.frame) {
42007
- const frameRect = group.frame.getMbr();
42023
+ if (group.groupItem) {
42024
+ const frameRect = group.groupItem.getMbr();
42008
42025
  frameRect.borderColor = FRAME_HIGHLIGHTER_BORDER_COLOR;
42009
42026
  frameRect.strokeWidth = 0.3;
42010
42027
  frameRect.render(context);
@@ -42099,7 +42116,7 @@ class AddFrame extends BoardTool {
42099
42116
  return true;
42100
42117
  }
42101
42118
  addNextTo() {
42102
- const framesInView = this.board.items.getFramesInView();
42119
+ const framesInView = this.board.items.getItemsInView().filter((item) => item instanceof Frame);
42103
42120
  if (framesInView.length === 0) {
42104
42121
  if (this.shape === "Custom") {
42105
42122
  const { x, y } = this.frame.getLastFrameScale();
@@ -42111,7 +42128,7 @@ class AddFrame extends BoardTool {
42111
42128
  }
42112
42129
  this.transformToCenter();
42113
42130
  } else {
42114
- const frames = this.board.items.listFrames().filter((frame2) => frame2 !== this.frame);
42131
+ const frames = this.board.items.listAll().filter((frame2) => frame2 instanceof Frame && frame2 !== this.frame);
42115
42132
  let nextTo = framesInView.reduce((rightest, frame2) => {
42116
42133
  if (frame2.getMbr().right > rightest.getMbr().right) {
42117
42134
  rightest = frame2;
@@ -43289,17 +43306,17 @@ function createCanvasDrawer(board) {
43289
43306
  const realRight = realLeft + adjustedWidth;
43290
43307
  const realBottom = realTop + adjustedHeight;
43291
43308
  const containerMbr = new Mbr(realLeft, realTop, realRight, realBottom);
43292
- const frames = board.items.getFramesEnclosedOrCrossed(containerMbr.left, containerMbr.top, containerMbr.right, containerMbr.bottom);
43293
- if (frames) {
43309
+ const groups = board.items.getGroupItemsEnclosedOrCrossed(containerMbr.left, containerMbr.top, containerMbr.right, containerMbr.bottom);
43310
+ if (groups) {
43294
43311
  drawnItemsMap?.forEach(({ mbr }) => {
43295
43312
  mbr.transform(currMatrix);
43296
43313
  });
43297
- frames.forEach((frame) => {
43314
+ groups.forEach((group) => {
43298
43315
  drawnItemsMap?.forEach(({ mbr, item }, key) => {
43299
- if (item.itemType === "Frame") {
43316
+ if ("canBeNested" in item && !item.canBeNested) {
43300
43317
  return;
43301
43318
  }
43302
- if (lastCreatedCanvas && (!drawnItemsMap.get(frame.getId()) || item.parent !== frame.getId()) && frame.handleNesting(mbr)) {
43319
+ if (lastCreatedCanvas && (!drawnItemsMap.get(group.getId()) || item.parent !== group.getId()) && group.handleNesting(mbr)) {
43303
43320
  const div = createBorderDivForItem(mbr, lastCreatedCanvas);
43304
43321
  removeHighlighted(key);
43305
43322
  highlightedDivs.set(key, div);
@@ -45388,7 +45405,7 @@ class Tools extends ToolContext {
45388
45405
  this.subject.publish(this);
45389
45406
  }
45390
45407
  sortFrames() {
45391
- const frames = this.board.items.listFrames();
45408
+ const frames = this.board.items.listAll().filter((item) => item instanceof Frame);
45392
45409
  const sortedFrames = frames.sort((fr1, fr2) => {
45393
45410
  const mbr1 = fr1.getMbr();
45394
45411
  const mbr2 = fr2.getMbr();
@@ -49475,9 +49492,9 @@ function updateFrameChildren({
49475
49492
  board,
49476
49493
  nestingHighlighter
49477
49494
  }) {
49478
- const frames = board.items.getFramesEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
49495
+ const groups = board.items.getGroupItemsEnclosedOrCrossed(mbr.left, mbr.top, mbr.right, mbr.bottom);
49479
49496
  board.selection.items.list().forEach((item) => {
49480
- if (item instanceof Frame) {
49497
+ if ("getChildrenIds" in item && item.getChildrenIds()) {
49481
49498
  const currMbr = item.getMbr();
49482
49499
  const itemsToCheck = board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom);
49483
49500
  itemsToCheck.forEach((currItem) => {
@@ -49488,9 +49505,9 @@ function updateFrameChildren({
49488
49505
  }
49489
49506
  });
49490
49507
  } else {
49491
- frames.forEach((frame) => {
49492
- if (frame.handleNesting(item)) {
49493
- nestingHighlighter.add(frame, item);
49508
+ groups.forEach((group) => {
49509
+ if (group.handleNesting(item)) {
49510
+ nestingHighlighter.add(group, item);
49494
49511
  } else {
49495
49512
  nestingHighlighter.remove(item);
49496
49513
  }
@@ -50009,9 +50026,7 @@ class BoardSelection {
50009
50026
  }
50010
50027
  addAll() {
50011
50028
  const items = this.board.items.listAll().filter((item) => !item.transformation.isLocked);
50012
- const frames = this.board.items.listFrames().filter((item) => !item.transformation.isLocked);
50013
50029
  this.add(items);
50014
- this.add(frames);
50015
50030
  this.setContext("SelectByRect");
50016
50031
  }
50017
50032
  remove(value) {
@@ -50440,38 +50455,38 @@ class BoardSelection {
50440
50455
  }, undefined);
50441
50456
  if (selectedMbr) {
50442
50457
  const selectedMap = Object.fromEntries(selected.map((item) => [item.getId(), { item, nested: false }]));
50443
- const enclosedFrames = this.board.items.getFramesEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
50444
- enclosedFrames.forEach((frame) => {
50458
+ const enclosedGroups = this.board.items.getGroupItemsEnclosedOrCrossed(selectedMbr?.left, selectedMbr?.top, selectedMbr?.right, selectedMbr?.bottom);
50459
+ enclosedGroups.forEach((group) => {
50445
50460
  selected.forEach((item) => {
50446
- if (frame.handleNesting(item)) {
50447
- selectedMap[item.getId()].nested = frame;
50461
+ if (group.handleNesting(item)) {
50462
+ selectedMap[item.getId()].nested = group;
50448
50463
  }
50449
50464
  });
50450
50465
  });
50451
50466
  Object.values(selectedMap).forEach((val) => {
50452
- const parentFrame = this.board.items.getById(val.item.parent);
50453
- const isParentFrame = parentFrame instanceof Frame;
50454
- const parentFrameId = isParentFrame ? parentFrame.getId() : null;
50467
+ const parentGroup = this.board.items.getById(val.item.parent);
50468
+ const parentGroupId = parentGroup?.getId();
50455
50469
  if (val.nested) {
50456
- const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentFrameId);
50457
- if (isParentFrame && isRemoveChildFromFrame) {
50458
- parentFrame.emitRemoveChild([val.item]);
50470
+ const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentGroupId);
50471
+ if (parentGroupId && isRemoveChildFromFrame) {
50472
+ parentGroup?.removeChildItems([val.item]);
50459
50473
  }
50460
50474
  val.nested.addChildItems([val.item]);
50461
50475
  } else if (val.item.parent !== "Board") {
50462
- if (isParentFrame) {
50463
- parentFrame.emitRemoveChild([val.item]);
50476
+ if (parentGroupId) {
50477
+ parentGroup?.removeChildItems([val.item]);
50464
50478
  } else {
50465
50479
  console.warn(`Didnt find frame with id ${val.item.parent}`);
50466
50480
  }
50467
50481
  }
50468
- if (val.item instanceof Frame && checkFrames) {
50469
- const currFrame = val.item;
50470
- const currMbr = currFrame.getMbr();
50471
- const children = val.item.getChildrenIds().map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
50472
- const underFrame = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currFrame.getId());
50482
+ const childrenIds = val.item.getChildrenIds();
50483
+ if (childrenIds && checkFrames) {
50484
+ const currGroup = val.item;
50485
+ const currMbr = currGroup.getMbr();
50486
+ const children = childrenIds.map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
50487
+ const underGroup = this.board.items.getEnclosedOrCrossed(currMbr.left, currMbr.top, currMbr.right, currMbr.bottom).filter((item) => item.parent === "Board" || item.parent === currGroup.getId());
50473
50488
  const uniqueItems = new Set;
50474
- const toCheck = [...children, ...underFrame].filter((item) => {
50489
+ const toCheck = [...children, ...underGroup].filter((item) => {
50475
50490
  const id = item.getId();
50476
50491
  if (uniqueItems.has(id)) {
50477
50492
  return false;
@@ -50479,7 +50494,7 @@ class BoardSelection {
50479
50494
  uniqueItems.add(id);
50480
50495
  return true;
50481
50496
  });
50482
- currFrame.emitNesting(toCheck);
50497
+ currGroup.emitNesting(toCheck);
50483
50498
  }
50484
50499
  });
50485
50500
  }
@@ -52089,13 +52104,9 @@ class LayeredIndex {
52089
52104
  class SpatialIndex {
52090
52105
  subject = new Subject;
52091
52106
  itemsArray = [];
52092
- framesArray = [];
52093
52107
  itemsIndex = new LayeredIndex((item) => {
52094
52108
  return this.itemsArray.indexOf(item);
52095
52109
  });
52096
- framesIndex = new LayeredIndex((item) => {
52097
- return this.framesArray.indexOf(item);
52098
- });
52099
52110
  Mbr = new Mbr;
52100
52111
  items;
52101
52112
  constructor(view, pointer) {
@@ -52103,23 +52114,14 @@ class SpatialIndex {
52103
52114
  }
52104
52115
  clear() {
52105
52116
  this.itemsArray = [];
52106
- this.framesArray = [];
52107
52117
  this.itemsIndex = new LayeredIndex((item) => {
52108
52118
  return this.itemsArray.indexOf(item);
52109
52119
  });
52110
- this.framesIndex = new LayeredIndex((item) => {
52111
- return this.framesArray.indexOf(item);
52112
- });
52113
52120
  this.Mbr = new Mbr;
52114
52121
  }
52115
52122
  insert(item) {
52116
- if (item instanceof Frame) {
52117
- this.framesArray.push(item);
52118
- this.framesIndex.insert(item);
52119
- } else {
52120
- this.itemsArray.push(item);
52121
- this.itemsIndex.insert(item);
52122
- }
52123
+ this.itemsArray.push(item);
52124
+ this.itemsIndex.insert(item);
52123
52125
  if (conf.isNode()) {
52124
52126
  return;
52125
52127
  }
@@ -52132,11 +52134,7 @@ class SpatialIndex {
52132
52134
  this.subject.publish(this.items);
52133
52135
  }
52134
52136
  change = (item) => {
52135
- if (item instanceof Frame) {
52136
- this.framesIndex.change(item);
52137
- } else {
52138
- this.itemsIndex.change(item);
52139
- }
52137
+ this.itemsIndex.change(item);
52140
52138
  if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
52141
52139
  this.Mbr = item.getMbr().copy();
52142
52140
  } else {
@@ -52151,41 +52149,24 @@ class SpatialIndex {
52151
52149
  }
52152
52150
  if (item.parent !== "Board") {
52153
52151
  const parentFrame = this.items.getById(item.parent);
52154
- parentFrame?.emitRemoveChild(item);
52155
- }
52156
- if (item instanceof Frame) {
52157
- this.framesArray.splice(this.framesArray.indexOf(item), 1);
52158
- this.framesIndex.remove(item);
52159
- } else {
52160
- this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
52161
- this.itemsIndex.remove(item);
52152
+ parentFrame?.removeChildItems(item);
52162
52153
  }
52154
+ this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
52155
+ this.itemsIndex.remove(item);
52163
52156
  this.Mbr = new Mbr;
52164
- const allItems = [...this.itemsArray, ...this.framesArray];
52165
- allItems.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
52157
+ this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbr()]));
52166
52158
  this.subject.publish(this.items);
52167
52159
  }
52168
52160
  copy() {
52169
- const itemsData = this.itemsArray.map((item) => ({
52161
+ return this.itemsArray.map((item) => ({
52170
52162
  ...item.serialize(true),
52171
52163
  id: item.getId()
52172
52164
  }));
52173
- const framesData = this.framesArray.map((item) => ({
52174
- ...item.serialize(),
52175
- id: item.getId()
52176
- }));
52177
- return [...framesData, ...itemsData];
52178
52165
  }
52179
52166
  moveToZIndex(item, zIndex) {
52180
- if (item instanceof Frame) {
52181
- const index2 = this.framesArray.indexOf(item);
52182
- this.framesArray.splice(index2, 1);
52183
- this.framesArray.splice(zIndex, 0, item);
52184
- } else {
52185
- const index2 = this.itemsArray.indexOf(item);
52186
- this.itemsArray.splice(index2, 1);
52187
- this.itemsArray.splice(zIndex, 0, item);
52188
- }
52167
+ const index2 = this.itemsArray.indexOf(item);
52168
+ this.itemsArray.splice(index2, 1);
52169
+ this.itemsArray.splice(zIndex, 0, item);
52189
52170
  this.change(item);
52190
52171
  this.subject.publish(this.items);
52191
52172
  }
@@ -52199,17 +52180,10 @@ class SpatialIndex {
52199
52180
  this.itemsArray.forEach(this.change.bind(this));
52200
52181
  }
52201
52182
  sendToBack(item, shouldPublish = true) {
52202
- if (item instanceof Frame) {
52203
- const index2 = this.framesArray.indexOf(item);
52204
- this.framesArray.splice(index2, 1);
52205
- this.framesArray.unshift(item);
52206
- this.framesIndex.change(item);
52207
- } else {
52208
- const index2 = this.itemsArray.indexOf(item);
52209
- this.itemsArray.splice(index2, 1);
52210
- this.itemsArray.unshift(item);
52211
- this.itemsIndex.change(item);
52212
- }
52183
+ const index2 = this.itemsArray.indexOf(item);
52184
+ this.itemsArray.splice(index2, 1);
52185
+ this.itemsArray.unshift(item);
52186
+ this.itemsIndex.change(item);
52213
52187
  if (shouldPublish) {
52214
52188
  this.subject.publish(this.items);
52215
52189
  }
@@ -52225,17 +52199,10 @@ class SpatialIndex {
52225
52199
  this.itemsArray.forEach(this.change.bind(this));
52226
52200
  }
52227
52201
  bringToFront(item, shouldPublish = true) {
52228
- if (item instanceof Frame) {
52229
- const index2 = this.framesArray.indexOf(item);
52230
- this.framesArray.splice(index2, 1);
52231
- this.framesArray.push(item);
52232
- this.framesIndex.change(item);
52233
- } else {
52234
- const index2 = this.itemsArray.indexOf(item);
52235
- this.itemsArray.splice(index2, 1);
52236
- this.itemsArray.push(item);
52237
- this.itemsIndex.change(item);
52238
- }
52202
+ const index2 = this.itemsArray.indexOf(item);
52203
+ this.itemsArray.splice(index2, 1);
52204
+ this.itemsArray.push(item);
52205
+ this.itemsIndex.change(item);
52239
52206
  if (shouldPublish) {
52240
52207
  this.subject.publish(this.items);
52241
52208
  }
@@ -52274,37 +52241,24 @@ class SpatialIndex {
52274
52241
  if (item) {
52275
52242
  return item;
52276
52243
  }
52277
- const frame = this.framesArray.find((frame2) => frame2.getId() === id);
52278
- return frame;
52279
52244
  }
52280
52245
  findById(id) {
52281
52246
  return this.getById(id);
52282
52247
  }
52283
52248
  getEnclosed(left, top, right, bottom) {
52284
52249
  const mbr = new Mbr(left, top, right, bottom);
52285
- const enclosedItems = this.itemsIndex.getEnclosed(mbr);
52286
- const enclosedFrames = this.framesIndex.getEnclosed(mbr);
52287
- return enclosedFrames.concat(enclosedItems);
52250
+ return this.itemsIndex.getEnclosed(mbr);
52288
52251
  }
52289
52252
  getEnclosedOrCrossed(left, top, right, bottom) {
52290
52253
  const mbr = new Mbr(left, top, right, bottom);
52291
- const enclosedOrCrossedItems = this.itemsIndex.getEnclosedOrCrossedBy(mbr);
52292
- const enclosedOrCrossedFrames = this.framesIndex.getEnclosedOrCrossedBy(mbr);
52293
- return enclosedOrCrossedFrames.concat(enclosedOrCrossedItems);
52254
+ return this.itemsIndex.getEnclosedOrCrossedBy(mbr);
52294
52255
  }
52295
52256
  getUnderPoint(point5, tolerace = 5) {
52296
- const itemsUnderPoint = this.itemsIndex.getUnderPoint(point5, tolerace);
52297
- const framesUnderPoint = this.framesIndex.getUnderPoint(point5, tolerace);
52298
- return [...framesUnderPoint, ...itemsUnderPoint];
52257
+ return this.itemsIndex.getUnderPoint(point5, tolerace);
52299
52258
  }
52300
52259
  getRectsEnclosedOrCrossed(left, top, right, bottom) {
52301
52260
  const mbr = new Mbr(left, top, right, bottom);
52302
- const frames = this.framesIndex.getRectsEnclosedOrCrossedBy(mbr);
52303
- const woFrames = this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
52304
- return [...woFrames, ...frames];
52305
- }
52306
- getFramesEnclosedOrCrossed(left, top, right, bottom) {
52307
- return this.framesIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
52261
+ return this.itemsIndex.getRectsEnclosedOrCrossedBy(mbr);
52308
52262
  }
52309
52263
  getItemsEnclosedOrCrossed(left, top, right, bottom) {
52310
52264
  return this.itemsIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
@@ -52317,44 +52271,28 @@ class SpatialIndex {
52317
52271
  }
52318
52272
  getNearestTo(point5, maxItems, filter, maxDistance) {
52319
52273
  const nearestItems = this.itemsIndex.getNearestTo(point5, maxItems, filter, maxDistance);
52320
- const nearestFrames = this.framesIndex.getNearestTo(point5, maxItems, filter, maxDistance);
52321
- const combined = nearestItems.concat(nearestFrames);
52322
- combined.sort((aa, bb) => {
52274
+ nearestItems.sort((aa, bb) => {
52323
52275
  const distA = point5.getDistance(aa.getMbr().getCenter());
52324
52276
  const distB = point5.getDistance(bb.getMbr().getCenter());
52325
52277
  return distA - distB;
52326
52278
  });
52327
- return combined.slice(0, maxItems);
52279
+ return nearestItems.slice(0, maxItems);
52328
52280
  }
52329
52281
  list() {
52330
52282
  return this.itemsArray.concat();
52331
52283
  }
52332
- listFrames() {
52333
- return this.framesArray.concat();
52334
- }
52335
52284
  getZIndex(item) {
52336
- if (item instanceof Frame) {
52337
- return this.framesArray.indexOf(item);
52338
- } else {
52339
- return this.itemsArray.indexOf(item);
52340
- }
52285
+ return this.itemsArray.indexOf(item);
52341
52286
  }
52342
52287
  getLastZIndex() {
52343
- return this.itemsArray.length + this.framesArray.length - 1;
52288
+ return this.itemsArray.length - 1;
52344
52289
  }
52345
52290
  getByZIndex(index2) {
52346
- const totalItems = this.itemsArray.length + this.framesArray.length;
52347
52291
  if (index2 < this.itemsArray.length) {
52348
52292
  return this.itemsArray[index2];
52349
- } else if (index2 < totalItems) {
52350
- return this.framesArray[index2 - this.itemsArray.length];
52351
52293
  } else {
52352
52294
  const lastIndex = this.getLastZIndex();
52353
- if (index2 - this.itemsArray.length < this.framesArray.length) {
52354
- return this.framesArray[lastIndex];
52355
- } else {
52356
- return this.itemsArray[lastIndex];
52357
- }
52295
+ return this.itemsArray[lastIndex];
52358
52296
  }
52359
52297
  }
52360
52298
  }
@@ -52377,7 +52315,10 @@ class Items {
52377
52315
  return this.index.list();
52378
52316
  }
52379
52317
  listFrames() {
52380
- return this.index.listFrames();
52318
+ return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
52319
+ }
52320
+ listGroupItems() {
52321
+ return this.index.list().filter((item) => ("getChildrenIds" in item) && item.getChildrenIds());
52381
52322
  }
52382
52323
  getById(id) {
52383
52324
  return this.index.getById(id);
@@ -52391,8 +52332,8 @@ class Items {
52391
52332
  getEnclosedOrCrossed(left, top, right, bottom) {
52392
52333
  return this.index.getEnclosedOrCrossed(left, top, right, bottom);
52393
52334
  }
52394
- getFramesEnclosedOrCrossed(left, top, right, bottom) {
52395
- return this.index.getFramesEnclosedOrCrossed(left, top, right, bottom);
52335
+ getGroupItemsEnclosedOrCrossed(left, top, right, bottom) {
52336
+ return this.index.getEnclosedOrCrossed(left, top, right, bottom).filter((item) => item instanceof BaseItem && item.getChildrenIds());
52396
52337
  }
52397
52338
  getUnderPoint(point5, tolerance = 5) {
52398
52339
  return this.index.getUnderPoint(point5, tolerance);
@@ -52408,9 +52349,9 @@ class Items {
52408
52349
  const { left, top, right, bottom } = this.view.getMbr();
52409
52350
  return this.index.getItemsEnclosedOrCrossed(left, top, right, bottom);
52410
52351
  }
52411
- getFramesInView() {
52352
+ getGroupItemsInView() {
52412
52353
  const { left, top, right, bottom } = this.view.getMbr();
52413
- return this.index.getFramesEnclosedOrCrossed(left, top, right, bottom);
52354
+ return this.getGroupItemsEnclosedOrCrossed(left, top, right, bottom);
52414
52355
  }
52415
52356
  getComments() {
52416
52357
  return this.index.getComments();
@@ -52448,11 +52389,7 @@ class Items {
52448
52389
  if (nearest) {
52449
52390
  return [nearest];
52450
52391
  }
52451
- const frames = this.index.listFrames().filter((frame) => frame.isTextUnderPoint(this.pointer.point));
52452
- if (frames.length === 0 && unmodifiedSize !== 16) {
52453
- return this.getUnderPointer(16);
52454
- }
52455
- return frames;
52392
+ return [];
52456
52393
  }
52457
52394
  getNearPointer(maxDistance = 100, maxItems = 10, filter = () => true) {
52458
52395
  return this.index.getNearestTo(this.pointer.point, maxItems, filter, maxDistance);
@@ -52503,41 +52440,39 @@ class Items {
52503
52440
  });
52504
52441
  }
52505
52442
  render(context) {
52506
- const frames = this.getFramesInView();
52507
- const rest = this.getItemsInView();
52508
- const frameChildrenIds = [];
52509
- frames.forEach((frame) => {
52510
- frame.renderPath(context);
52511
- frame.getChildrenIds().map((id) => this.getById(id)).forEach((child) => {
52512
- if (child) {
52513
- frameChildrenIds.push(child.getId());
52514
- child.render(context);
52515
- }
52516
- });
52443
+ const items = this.getItemsInView();
52444
+ items.forEach((item) => {
52445
+ if (item.parent !== "Board") {
52446
+ item.render(context);
52447
+ }
52517
52448
  });
52518
- rest.filter((item) => !frameChildrenIds.includes(item.getId())).forEach((item) => item.render(context));
52519
- frames.forEach((frame) => frame.renderBorders(context));
52520
- frames.forEach((frame) => frame.renderName(context));
52521
52449
  }
52522
52450
  renderHTML(documentFactory) {
52523
- const frames = this.getFramesInView();
52524
- const rest = this.getItemsInView();
52525
- return this.getHTML(documentFactory, frames, rest);
52451
+ const items = this.getItemsInView();
52452
+ return this.getHTML(documentFactory, items);
52526
52453
  }
52527
52454
  getWholeHTML(documentFactory) {
52528
- const frames = this.listFrames();
52529
- const rest = this.listAll();
52530
- return this.getHTML(documentFactory, frames, rest);
52455
+ const items = this.listAll();
52456
+ return this.getHTML(documentFactory, items);
52531
52457
  }
52532
- getHTML(documentFactory, frames, rest) {
52533
- const lowestCoordinates = [...frames, ...rest].map((item) => item.getMbr()).reduce((acc, mbr) => ({
52458
+ getHTML(documentFactory, items) {
52459
+ const lowestCoordinates = items.map((item) => item.getMbr()).reduce((acc, mbr) => ({
52534
52460
  left: Math.min(acc.left, mbr.left),
52535
52461
  top: Math.min(acc.top, mbr.top)
52536
52462
  }), { left: 0, top: 0 });
52463
+ const groups = [];
52464
+ const rest = [];
52465
+ items.forEach((item) => {
52466
+ if ("getChildrenIds" in item && item.getChildrenIds()) {
52467
+ groups.push(item);
52468
+ } else {
52469
+ rest.push(item);
52470
+ }
52471
+ });
52537
52472
  const childrenMap = new Map;
52538
- const framesHTML = frames.map((frame) => {
52539
- frame.getChildrenIds().forEach((childId) => childrenMap.set(childId, frame.getId()));
52540
- const html4 = frame.renderHTML(documentFactory);
52473
+ const GroupsHTML = groups.map((group) => {
52474
+ group.getChildrenIds().forEach((childId) => childrenMap.set(childId, group.getId()));
52475
+ const html4 = group.renderHTML(documentFactory);
52541
52476
  translateElementBy(html4, -lowestCoordinates.left, -lowestCoordinates.top);
52542
52477
  return html4;
52543
52478
  });
@@ -52556,15 +52491,15 @@ class Items {
52556
52491
  });
52557
52492
  for (const item of restHTML) {
52558
52493
  const parentFrameId = childrenMap.get(item.id);
52559
- const frame = framesHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
52560
- if (frame) {
52561
- positionRelatively(item, frame);
52562
- frame.appendChild(item);
52494
+ const group = GroupsHTML.find((el) => parentFrameId !== undefined && el.id === parentFrameId);
52495
+ if (group) {
52496
+ positionRelatively(item, group);
52497
+ group.appendChild(item);
52563
52498
  }
52564
52499
  }
52565
52500
  let result = "";
52566
- for (const frame of framesHTML) {
52567
- result += frame.outerHTML;
52501
+ for (const group of GroupsHTML) {
52502
+ result += group.outerHTML;
52568
52503
  }
52569
52504
  for (const item of restHTML) {
52570
52505
  if (!childrenMap.get(item.id)) {
@@ -53209,24 +53144,24 @@ class Board {
53209
53144
  }
53210
53145
  handleNesting(items) {
53211
53146
  const arrayed = Array.isArray(items) ? items : [items];
53212
- const framesMap = new Map;
53147
+ const groupsMap = new Map;
53213
53148
  arrayed.forEach((item) => {
53214
53149
  const itemCenter = item.getMbr().getCenter();
53215
- const frame = this.items.getFramesInView().filter((frame2) => frame2.handleNesting(item)).reduce((acc, frame2) => {
53216
- if (!acc || frame2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
53217
- acc = frame2;
53150
+ const groupItem = this.items.getGroupItemsInView().filter((groupItem2) => groupItem2.handleNesting(item)).reduce((acc, groupItem2) => {
53151
+ if (!acc || groupItem2.getDistanceToPoint(itemCenter) > acc.getDistanceToPoint(itemCenter)) {
53152
+ acc = groupItem2;
53218
53153
  }
53219
53154
  return acc;
53220
53155
  }, undefined);
53221
- if (frame) {
53222
- if (!framesMap.has(frame)) {
53223
- framesMap.set(frame, []);
53156
+ if (groupItem) {
53157
+ if (!groupsMap.has(groupItem)) {
53158
+ groupsMap.set(groupItem, []);
53224
53159
  }
53225
- framesMap.get(frame)?.push(item);
53160
+ groupsMap.get(groupItem)?.push(item);
53226
53161
  }
53227
53162
  });
53228
- framesMap.forEach((items2, frame) => {
53229
- frame.addChildItems(items2);
53163
+ groupsMap.forEach((items2, group) => {
53164
+ group.addChildItems(items2);
53230
53165
  });
53231
53166
  }
53232
53167
  createItem(id, data) {
@@ -53939,7 +53874,7 @@ class Board {
53939
53874
  return this.items.findById(item.getId()) !== undefined;
53940
53875
  }
53941
53876
  getMaxFrameSerial() {
53942
- const existingNames = this.items.listFrames().map((frame) => frame.text.getTextString().length === 0 ? frame.text.placeholderText : frame.text.getTextString());
53877
+ const existingNames = this.items.listGroupItems().map((frame) => frame.getRichText()?.getTextString().length === 0 ? frame.getRichText()?.placeholderText || "" : frame.getRichText()?.getTextString() || "");
53943
53878
  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);
53944
53879
  }
53945
53880
  setInterfaceType(interfaceType) {