microboard-temp 0.14.3 → 0.14.5

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.
@@ -58114,13 +58114,19 @@ var init_findOrthogonalPath = __esm(() => {
58114
58114
  });
58115
58115
 
58116
58116
  // src/Items/Connector/getLine/getOrthogonalLine.ts
58117
+ function getItemWorldMbr(item) {
58118
+ if (item instanceof BaseItem && item.parent !== "Board") {
58119
+ return item.getWorldMbr();
58120
+ }
58121
+ return item.getMbr();
58122
+ }
58117
58123
  function getOrthogonalLine(start, end, middle, skipObstacles = false) {
58118
58124
  const obstacles = [];
58119
58125
  if (start.pointType !== "Board" && !skipObstacles) {
58120
- obstacles.push(start.item.getMbr());
58126
+ obstacles.push(getItemWorldMbr(start.item));
58121
58127
  }
58122
58128
  if (end.pointType !== "Board" && !skipObstacles) {
58123
- obstacles.push(end.item.getMbr());
58129
+ obstacles.push(getItemWorldMbr(end.item));
58124
58130
  }
58125
58131
  const { lines, newStart, newEnd } = findOrthogonalPath(start, end, obstacles, middle ? [middle] : undefined);
58126
58132
  if (lines.length === 0) {
@@ -58134,6 +58140,7 @@ function getOrthogonalLine(start, end, middle, skipObstacles = false) {
58134
58140
  var init_getOrthogonalLine = __esm(() => {
58135
58141
  init_Items();
58136
58142
  init_findOrthogonalPath();
58143
+ init_BaseItem();
58137
58144
  });
58138
58145
 
58139
58146
  // src/Items/Connector/getLine/getStraightLine.ts
@@ -58168,6 +58175,175 @@ var init_getLine = __esm(() => {
58168
58175
  init_getStraightLine();
58169
58176
  });
58170
58177
 
58178
+ // src/Items/Group/Group.ts
58179
+ var Group;
58180
+ var init_Group = __esm(() => {
58181
+ init_Mbr();
58182
+ init_Point();
58183
+ init_BaseItem();
58184
+ Group = class Group extends BaseItem {
58185
+ events;
58186
+ itemType = "Group";
58187
+ parent = "Board";
58188
+ subject = new Subject;
58189
+ transformationRenderBlock = undefined;
58190
+ isLockedGroup = false;
58191
+ static movingGroupId = null;
58192
+ constructor(board, events, childIds = [], id = "") {
58193
+ super(board, id, undefined, true);
58194
+ this.events = events;
58195
+ this.canBeNested = true;
58196
+ if (childIds.length > 0) {
58197
+ this.applyAddChildren(childIds);
58198
+ }
58199
+ }
58200
+ isClosed() {
58201
+ return false;
58202
+ }
58203
+ getRichText() {
58204
+ return null;
58205
+ }
58206
+ apply(op) {
58207
+ switch (op.class) {
58208
+ case "Transformation":
58209
+ super.apply(op);
58210
+ this.updateMbr();
58211
+ Group.movingGroupId = this.id;
58212
+ for (const child of this.index.listAll()) {
58213
+ child.subject.publish(child);
58214
+ }
58215
+ Group.movingGroupId = null;
58216
+ break;
58217
+ case "Group":
58218
+ if (op.method === "addChild") {
58219
+ this.applyAddChildren([op.childId]);
58220
+ } else if (op.method === "removeChild") {
58221
+ this.applyRemoveChildren([op.childId]);
58222
+ } else {
58223
+ super.apply(op);
58224
+ }
58225
+ break;
58226
+ default:
58227
+ super.apply(op);
58228
+ return;
58229
+ }
58230
+ this.subject.publish(this);
58231
+ }
58232
+ emit(operation) {
58233
+ if (this.events) {
58234
+ const command = new GroupCommand([this], operation);
58235
+ command.apply();
58236
+ this.events.emit(operation, command);
58237
+ } else {
58238
+ this.apply(operation);
58239
+ }
58240
+ }
58241
+ setId(id) {
58242
+ this.id = id;
58243
+ this.transformation.setId(id);
58244
+ return this;
58245
+ }
58246
+ getMbr() {
58247
+ const children = this.index.listAll();
58248
+ if (children.length === 0) {
58249
+ return new Mbr(this.left, this.top, this.right, this.bottom);
58250
+ }
58251
+ const groupWorldMatrix = this.getWorldMatrix();
58252
+ let left = Number.MAX_SAFE_INTEGER;
58253
+ let top = Number.MAX_SAFE_INTEGER;
58254
+ let right = Number.MIN_SAFE_INTEGER;
58255
+ let bottom = Number.MIN_SAFE_INTEGER;
58256
+ for (const child of children) {
58257
+ const childLocalMbr = child.getMbr();
58258
+ const corners = [
58259
+ new Point(childLocalMbr.left, childLocalMbr.top),
58260
+ new Point(childLocalMbr.right, childLocalMbr.top),
58261
+ new Point(childLocalMbr.right, childLocalMbr.bottom),
58262
+ new Point(childLocalMbr.left, childLocalMbr.bottom)
58263
+ ];
58264
+ for (const corner of corners) {
58265
+ groupWorldMatrix.apply(corner);
58266
+ if (corner.x < left)
58267
+ left = corner.x;
58268
+ if (corner.y < top)
58269
+ top = corner.y;
58270
+ if (corner.x > right)
58271
+ right = corner.x;
58272
+ if (corner.y > bottom)
58273
+ bottom = corner.y;
58274
+ }
58275
+ }
58276
+ const mbr = new Mbr(left, top, right, bottom);
58277
+ this.left = left;
58278
+ this.top = top;
58279
+ this.right = right;
58280
+ this.bottom = bottom;
58281
+ return mbr;
58282
+ }
58283
+ updateMbr() {
58284
+ this.getMbr();
58285
+ }
58286
+ getChildrenIds() {
58287
+ return this.index.listAll().map((item) => item.getId());
58288
+ }
58289
+ getChildren() {
58290
+ return this.index.listAll();
58291
+ }
58292
+ getLinkTo() {
58293
+ return this.linkTo.link;
58294
+ }
58295
+ serialize() {
58296
+ return {
58297
+ id: this.id,
58298
+ itemType: "Group",
58299
+ childIds: this.getChildrenIds(),
58300
+ transformation: this.transformation.serialize(),
58301
+ isLockedGroup: this.isLockedGroup
58302
+ };
58303
+ }
58304
+ deserialize(data) {
58305
+ if (data.transformation) {
58306
+ this.transformation.deserialize(data.transformation);
58307
+ }
58308
+ if (data.childIds && data.childIds.length > 0) {
58309
+ this.applyAddChildren(data.childIds);
58310
+ }
58311
+ if (data.isLockedGroup !== undefined) {
58312
+ this.isLockedGroup = data.isLockedGroup;
58313
+ }
58314
+ this.updateMbr();
58315
+ this.subject.publish(this);
58316
+ return this;
58317
+ }
58318
+ getId() {
58319
+ return this.id;
58320
+ }
58321
+ getIntersectionPoints(segment) {
58322
+ const lines = this.getMbr().getLines();
58323
+ const initPoints = [];
58324
+ return lines.reduce((acc, line) => {
58325
+ const intersections = line.getIntersectionPoints(segment);
58326
+ if (intersections.length > 0) {
58327
+ acc.push(...intersections);
58328
+ }
58329
+ return acc;
58330
+ }, initPoints);
58331
+ }
58332
+ render(context) {
58333
+ if (this.transformationRenderBlock) {
58334
+ return;
58335
+ }
58336
+ const ctx = context.ctx;
58337
+ ctx.save();
58338
+ this.transformation.applyToContext(ctx);
58339
+ for (const child of this.index.listAll()) {
58340
+ child.render(context);
58341
+ }
58342
+ ctx.restore();
58343
+ }
58344
+ };
58345
+ });
58346
+
58171
58347
  // src/Items/Connector/ConnectorTypes.ts
58172
58348
  var ConnectionLineWidths, CONNECTOR_COLOR = "rgb(20, 21, 26)", CONNECTOR_LINE_WIDTH = 1, CONNECTOR_BORDER_STYLE = "solid", DEFAULT_END_POINTER = "TriangleFilled", CONNECTOR_POINTER_TYPES;
58173
58349
  var init_ConnectorTypes = __esm(() => {
@@ -58276,6 +58452,7 @@ var init_Connector = __esm(() => {
58276
58452
  init_Settings();
58277
58453
  init_transformOps();
58278
58454
  init_BaseItem();
58455
+ init_Group();
58279
58456
  init_Color();
58280
58457
  init_ConnectorTypes();
58281
58458
  init_connectorOps();
@@ -58365,8 +58542,9 @@ var init_Connector = __esm(() => {
58365
58542
  const point5 = this.startPoint;
58366
58543
  if (point5.pointType !== "Board") {
58367
58544
  point5.recalculatePoint();
58368
- const j1 = this.smartJumpStartEdge();
58369
- const j2 = this.smartJumpEndEdge();
58545
+ const isGroupMoving = Group.movingGroupId !== null;
58546
+ const j1 = isGroupMoving ? false : this.smartJumpStartEdge();
58547
+ const j2 = isGroupMoving ? false : this.smartJumpEndEdge();
58370
58548
  if (!j1 && !j2) {
58371
58549
  this.updatePaths();
58372
58550
  this.subject.publish(this);
@@ -58377,8 +58555,9 @@ var init_Connector = __esm(() => {
58377
58555
  const point5 = this.endPoint;
58378
58556
  if (point5.pointType !== "Board") {
58379
58557
  point5.recalculatePoint();
58380
- const j1 = this.smartJumpEndEdge();
58381
- const j2 = this.smartJumpStartEdge();
58558
+ const isGroupMoving = Group.movingGroupId !== null;
58559
+ const j1 = isGroupMoving ? false : this.smartJumpEndEdge();
58560
+ const j2 = isGroupMoving ? false : this.smartJumpStartEdge();
58382
58561
  if (!j1 && !j2) {
58383
58562
  this.updatePaths();
58384
58563
  this.subject.publish(this);
@@ -63691,172 +63870,6 @@ var init_Placeholder2 = __esm(() => {
63691
63870
  init_Placeholder();
63692
63871
  });
63693
63872
 
63694
- // src/Items/Group/Group.ts
63695
- var Group;
63696
- var init_Group = __esm(() => {
63697
- init_Mbr();
63698
- init_Point();
63699
- init_BaseItem();
63700
- Group = class Group extends BaseItem {
63701
- events;
63702
- itemType = "Group";
63703
- parent = "Board";
63704
- subject = new Subject;
63705
- transformationRenderBlock = undefined;
63706
- isLockedGroup = false;
63707
- constructor(board, events, childIds = [], id = "") {
63708
- super(board, id, undefined, true);
63709
- this.events = events;
63710
- this.canBeNested = true;
63711
- if (childIds.length > 0) {
63712
- this.applyAddChildren(childIds);
63713
- }
63714
- }
63715
- isClosed() {
63716
- return false;
63717
- }
63718
- getRichText() {
63719
- return null;
63720
- }
63721
- apply(op) {
63722
- switch (op.class) {
63723
- case "Transformation":
63724
- super.apply(op);
63725
- this.updateMbr();
63726
- for (const child of this.index.listAll()) {
63727
- child.subject.publish(child);
63728
- }
63729
- break;
63730
- case "Group":
63731
- if (op.method === "addChild") {
63732
- this.applyAddChildren([op.childId]);
63733
- } else if (op.method === "removeChild") {
63734
- this.applyRemoveChildren([op.childId]);
63735
- } else {
63736
- super.apply(op);
63737
- }
63738
- break;
63739
- default:
63740
- super.apply(op);
63741
- return;
63742
- }
63743
- this.subject.publish(this);
63744
- }
63745
- emit(operation) {
63746
- if (this.events) {
63747
- const command = new GroupCommand([this], operation);
63748
- command.apply();
63749
- this.events.emit(operation, command);
63750
- } else {
63751
- this.apply(operation);
63752
- }
63753
- }
63754
- setId(id) {
63755
- this.id = id;
63756
- this.transformation.setId(id);
63757
- return this;
63758
- }
63759
- getMbr() {
63760
- const children = this.index.listAll();
63761
- if (children.length === 0) {
63762
- return new Mbr(this.left, this.top, this.right, this.bottom);
63763
- }
63764
- const groupWorldMatrix = this.getWorldMatrix();
63765
- let left = Number.MAX_SAFE_INTEGER;
63766
- let top = Number.MAX_SAFE_INTEGER;
63767
- let right = Number.MIN_SAFE_INTEGER;
63768
- let bottom = Number.MIN_SAFE_INTEGER;
63769
- for (const child of children) {
63770
- const childLocalMbr = child.getMbr();
63771
- const corners = [
63772
- new Point(childLocalMbr.left, childLocalMbr.top),
63773
- new Point(childLocalMbr.right, childLocalMbr.top),
63774
- new Point(childLocalMbr.right, childLocalMbr.bottom),
63775
- new Point(childLocalMbr.left, childLocalMbr.bottom)
63776
- ];
63777
- for (const corner of corners) {
63778
- groupWorldMatrix.apply(corner);
63779
- if (corner.x < left)
63780
- left = corner.x;
63781
- if (corner.y < top)
63782
- top = corner.y;
63783
- if (corner.x > right)
63784
- right = corner.x;
63785
- if (corner.y > bottom)
63786
- bottom = corner.y;
63787
- }
63788
- }
63789
- const mbr = new Mbr(left, top, right, bottom);
63790
- this.left = left;
63791
- this.top = top;
63792
- this.right = right;
63793
- this.bottom = bottom;
63794
- return mbr;
63795
- }
63796
- updateMbr() {
63797
- this.getMbr();
63798
- }
63799
- getChildrenIds() {
63800
- return this.index.listAll().map((item) => item.getId());
63801
- }
63802
- getChildren() {
63803
- return this.index.listAll();
63804
- }
63805
- getLinkTo() {
63806
- return this.linkTo.link;
63807
- }
63808
- serialize() {
63809
- return {
63810
- id: this.id,
63811
- itemType: "Group",
63812
- childIds: this.getChildrenIds(),
63813
- transformation: this.transformation.serialize(),
63814
- isLockedGroup: this.isLockedGroup
63815
- };
63816
- }
63817
- deserialize(data) {
63818
- if (data.transformation) {
63819
- this.transformation.deserialize(data.transformation);
63820
- }
63821
- if (data.childIds && data.childIds.length > 0) {
63822
- this.applyAddChildren(data.childIds);
63823
- }
63824
- if (data.isLockedGroup !== undefined) {
63825
- this.isLockedGroup = data.isLockedGroup;
63826
- }
63827
- this.updateMbr();
63828
- this.subject.publish(this);
63829
- return this;
63830
- }
63831
- getId() {
63832
- return this.id;
63833
- }
63834
- getIntersectionPoints(segment) {
63835
- const lines = this.getMbr().getLines();
63836
- const initPoints = [];
63837
- return lines.reduce((acc, line) => {
63838
- const intersections = line.getIntersectionPoints(segment);
63839
- if (intersections.length > 0) {
63840
- acc.push(...intersections);
63841
- }
63842
- return acc;
63843
- }, initPoints);
63844
- }
63845
- render(context) {
63846
- if (this.transformationRenderBlock) {
63847
- return;
63848
- }
63849
- const ctx = context.ctx;
63850
- ctx.save();
63851
- this.transformation.applyToContext(ctx);
63852
- for (const child of this.index.listAll()) {
63853
- child.render(context);
63854
- }
63855
- ctx.restore();
63856
- }
63857
- };
63858
- });
63859
-
63860
63873
  // src/Items/Group/index.ts
63861
63874
  var init_Group2 = __esm(() => {
63862
63875
  init_Group();
@@ -64306,26 +64319,18 @@ class ConnectorSnap {
64306
64319
  } else if (anchor) {
64307
64320
  this.controlPoint = getFixedPoint(item, anchor.getCenter());
64308
64321
  } else if (point5) {
64309
- this.controlPoint = getFixedPoint(item, point5.getCenter());
64322
+ const nearest2 = item.getNearestEdgePointTo(pointer);
64323
+ this.controlPoint = getFixedPoint(item, nearest2);
64310
64324
  } else {
64311
- this.controlPoint = getFixedPoint(item, pointer);
64325
+ if (this.hover.isTimeoutElapsed) {
64326
+ this.controlPoint = getFixedPoint(item, pointer);
64327
+ } else {
64328
+ this.controlPoint = getFixedPoint(item, pointer);
64329
+ }
64312
64330
  }
64313
64331
  }
64314
64332
  setHover() {
64315
- let hover = this.board.items.getUnderPointer(0)[0];
64316
- if (hover instanceof BaseItem && hover.index) {
64317
- const group = hover;
64318
- const inverse = group.getWorldMatrix().getInverse();
64319
- const pointer = this.board.pointer.point;
64320
- const localPointer = pointer.copy();
64321
- localPointer.transform(inverse);
64322
- for (const child of group.index.listAll()) {
64323
- if (child.getMbr().isUnderPoint(localPointer)) {
64324
- hover = child;
64325
- break;
64326
- }
64327
- }
64328
- }
64333
+ const hover = this.board.items.getUnderPointer(0)[0];
64329
64334
  if (hover) {
64330
64335
  if (hover !== this.hover.item) {
64331
64336
  this.hover = {
@@ -64382,18 +64387,8 @@ class ConnectorSnap {
64382
64387
  return nearest;
64383
64388
  }
64384
64389
  getClosestPointOnItem(item, position4) {
64385
- let worldEdgePoint;
64386
- if (item instanceof BaseItem && item.parent !== "Board") {
64387
- const parentMatrix = item.getParentWorldMatrix();
64388
- const localPos = position4.copy();
64389
- localPos.transform(parentMatrix.getInverse());
64390
- const localEdge = item.getNearestEdgePointTo(localPos);
64391
- worldEdgePoint = localEdge.copy();
64392
- parentMatrix.apply(worldEdgePoint);
64393
- } else {
64394
- worldEdgePoint = item.getNearestEdgePointTo(position4);
64395
- }
64396
- return getFixedPoint(item, worldEdgePoint);
64390
+ const nearestEdgePoint = item.getNearestEdgePointTo(position4);
64391
+ return getFixedPoint(item, nearestEdgePoint);
64397
64392
  }
64398
64393
  isNearBorder(item) {
64399
64394
  if (!item) {
@@ -64422,15 +64417,10 @@ class ConnectorSnap {
64422
64417
  }
64423
64418
  }
64424
64419
  setAnchors(item) {
64425
- const localPoints = item.getSnapAnchorPoints();
64426
- if (!localPoints) {
64420
+ const points = item.getSnapAnchorPoints();
64421
+ if (!points) {
64427
64422
  return;
64428
64423
  }
64429
- const points = item instanceof BaseItem && item.parent !== "Board" ? localPoints.map((p3) => {
64430
- const wp = p3.copy();
64431
- item.getParentWorldMatrix().apply(wp);
64432
- return wp;
64433
- }) : localPoints;
64434
64424
  const anchors = [];
64435
64425
  for (const { x, y } of points) {
64436
64426
  anchors.push(new Anchor(x, y, 5, this.color.anchorBorder, this.color.anchorBackground, 1));
@@ -64464,19 +64454,9 @@ class ConnectorSnap {
64464
64454
  const { item, anchor } = this.snap;
64465
64455
  if (item) {
64466
64456
  if (!anchor) {
64467
- let edgePoint;
64468
- if (item instanceof BaseItem && item.parent !== "Board") {
64469
- const parentMatrix = item.getParentWorldMatrix();
64470
- const localPointer = pointer.copy();
64471
- localPointer.transform(parentMatrix.getInverse());
64472
- const localEdge = item.getNearestEdgePointTo(localPointer);
64473
- edgePoint = localEdge.copy();
64474
- parentMatrix.apply(edgePoint);
64475
- } else {
64476
- edgePoint = item.getNearestEdgePointTo(pointer);
64477
- }
64478
- if (edgePoint.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
64479
- this.snap.point = new Anchor(edgePoint.x, edgePoint.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
64457
+ const point5 = item.getNearestEdgePointTo(pointer);
64458
+ if (point5.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
64459
+ this.snap.point = new Anchor(point5.x, point5.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
64480
64460
  } else {
64481
64461
  this.snap.point = null;
64482
64462
  }
@@ -64505,7 +64485,6 @@ class ConnectorSnap {
64505
64485
  }
64506
64486
  var init_ConnectorSnap = __esm(() => {
64507
64487
  init_ControlPoint();
64508
- init_BaseItem2();
64509
64488
  init_Anchor2();
64510
64489
  init_Connector();
64511
64490
  });