microboard-temp 0.14.3 → 0.14.4

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.
@@ -58168,6 +58168,175 @@ var init_getLine = __esm(() => {
58168
58168
  init_getStraightLine();
58169
58169
  });
58170
58170
 
58171
+ // src/Items/Group/Group.ts
58172
+ var Group;
58173
+ var init_Group = __esm(() => {
58174
+ init_Mbr();
58175
+ init_Point();
58176
+ init_BaseItem();
58177
+ Group = class Group extends BaseItem {
58178
+ events;
58179
+ itemType = "Group";
58180
+ parent = "Board";
58181
+ subject = new Subject;
58182
+ transformationRenderBlock = undefined;
58183
+ isLockedGroup = false;
58184
+ static movingGroupId = null;
58185
+ constructor(board, events, childIds = [], id = "") {
58186
+ super(board, id, undefined, true);
58187
+ this.events = events;
58188
+ this.canBeNested = true;
58189
+ if (childIds.length > 0) {
58190
+ this.applyAddChildren(childIds);
58191
+ }
58192
+ }
58193
+ isClosed() {
58194
+ return false;
58195
+ }
58196
+ getRichText() {
58197
+ return null;
58198
+ }
58199
+ apply(op) {
58200
+ switch (op.class) {
58201
+ case "Transformation":
58202
+ super.apply(op);
58203
+ this.updateMbr();
58204
+ Group.movingGroupId = this.id;
58205
+ for (const child of this.index.listAll()) {
58206
+ child.subject.publish(child);
58207
+ }
58208
+ Group.movingGroupId = null;
58209
+ break;
58210
+ case "Group":
58211
+ if (op.method === "addChild") {
58212
+ this.applyAddChildren([op.childId]);
58213
+ } else if (op.method === "removeChild") {
58214
+ this.applyRemoveChildren([op.childId]);
58215
+ } else {
58216
+ super.apply(op);
58217
+ }
58218
+ break;
58219
+ default:
58220
+ super.apply(op);
58221
+ return;
58222
+ }
58223
+ this.subject.publish(this);
58224
+ }
58225
+ emit(operation) {
58226
+ if (this.events) {
58227
+ const command = new GroupCommand([this], operation);
58228
+ command.apply();
58229
+ this.events.emit(operation, command);
58230
+ } else {
58231
+ this.apply(operation);
58232
+ }
58233
+ }
58234
+ setId(id) {
58235
+ this.id = id;
58236
+ this.transformation.setId(id);
58237
+ return this;
58238
+ }
58239
+ getMbr() {
58240
+ const children = this.index.listAll();
58241
+ if (children.length === 0) {
58242
+ return new Mbr(this.left, this.top, this.right, this.bottom);
58243
+ }
58244
+ const groupWorldMatrix = this.getWorldMatrix();
58245
+ let left = Number.MAX_SAFE_INTEGER;
58246
+ let top = Number.MAX_SAFE_INTEGER;
58247
+ let right = Number.MIN_SAFE_INTEGER;
58248
+ let bottom = Number.MIN_SAFE_INTEGER;
58249
+ for (const child of children) {
58250
+ const childLocalMbr = child.getMbr();
58251
+ const corners = [
58252
+ new Point(childLocalMbr.left, childLocalMbr.top),
58253
+ new Point(childLocalMbr.right, childLocalMbr.top),
58254
+ new Point(childLocalMbr.right, childLocalMbr.bottom),
58255
+ new Point(childLocalMbr.left, childLocalMbr.bottom)
58256
+ ];
58257
+ for (const corner of corners) {
58258
+ groupWorldMatrix.apply(corner);
58259
+ if (corner.x < left)
58260
+ left = corner.x;
58261
+ if (corner.y < top)
58262
+ top = corner.y;
58263
+ if (corner.x > right)
58264
+ right = corner.x;
58265
+ if (corner.y > bottom)
58266
+ bottom = corner.y;
58267
+ }
58268
+ }
58269
+ const mbr = new Mbr(left, top, right, bottom);
58270
+ this.left = left;
58271
+ this.top = top;
58272
+ this.right = right;
58273
+ this.bottom = bottom;
58274
+ return mbr;
58275
+ }
58276
+ updateMbr() {
58277
+ this.getMbr();
58278
+ }
58279
+ getChildrenIds() {
58280
+ return this.index.listAll().map((item) => item.getId());
58281
+ }
58282
+ getChildren() {
58283
+ return this.index.listAll();
58284
+ }
58285
+ getLinkTo() {
58286
+ return this.linkTo.link;
58287
+ }
58288
+ serialize() {
58289
+ return {
58290
+ id: this.id,
58291
+ itemType: "Group",
58292
+ childIds: this.getChildrenIds(),
58293
+ transformation: this.transformation.serialize(),
58294
+ isLockedGroup: this.isLockedGroup
58295
+ };
58296
+ }
58297
+ deserialize(data) {
58298
+ if (data.transformation) {
58299
+ this.transformation.deserialize(data.transformation);
58300
+ }
58301
+ if (data.childIds && data.childIds.length > 0) {
58302
+ this.applyAddChildren(data.childIds);
58303
+ }
58304
+ if (data.isLockedGroup !== undefined) {
58305
+ this.isLockedGroup = data.isLockedGroup;
58306
+ }
58307
+ this.updateMbr();
58308
+ this.subject.publish(this);
58309
+ return this;
58310
+ }
58311
+ getId() {
58312
+ return this.id;
58313
+ }
58314
+ getIntersectionPoints(segment) {
58315
+ const lines = this.getMbr().getLines();
58316
+ const initPoints = [];
58317
+ return lines.reduce((acc, line) => {
58318
+ const intersections = line.getIntersectionPoints(segment);
58319
+ if (intersections.length > 0) {
58320
+ acc.push(...intersections);
58321
+ }
58322
+ return acc;
58323
+ }, initPoints);
58324
+ }
58325
+ render(context) {
58326
+ if (this.transformationRenderBlock) {
58327
+ return;
58328
+ }
58329
+ const ctx = context.ctx;
58330
+ ctx.save();
58331
+ this.transformation.applyToContext(ctx);
58332
+ for (const child of this.index.listAll()) {
58333
+ child.render(context);
58334
+ }
58335
+ ctx.restore();
58336
+ }
58337
+ };
58338
+ });
58339
+
58171
58340
  // src/Items/Connector/ConnectorTypes.ts
58172
58341
  var ConnectionLineWidths, CONNECTOR_COLOR = "rgb(20, 21, 26)", CONNECTOR_LINE_WIDTH = 1, CONNECTOR_BORDER_STYLE = "solid", DEFAULT_END_POINTER = "TriangleFilled", CONNECTOR_POINTER_TYPES;
58173
58342
  var init_ConnectorTypes = __esm(() => {
@@ -58276,6 +58445,7 @@ var init_Connector = __esm(() => {
58276
58445
  init_Settings();
58277
58446
  init_transformOps();
58278
58447
  init_BaseItem();
58448
+ init_Group();
58279
58449
  init_Color();
58280
58450
  init_ConnectorTypes();
58281
58451
  init_connectorOps();
@@ -58365,8 +58535,9 @@ var init_Connector = __esm(() => {
58365
58535
  const point5 = this.startPoint;
58366
58536
  if (point5.pointType !== "Board") {
58367
58537
  point5.recalculatePoint();
58368
- const j1 = this.smartJumpStartEdge();
58369
- const j2 = this.smartJumpEndEdge();
58538
+ const isGroupMoving = Group.movingGroupId !== null;
58539
+ const j1 = isGroupMoving ? false : this.smartJumpStartEdge();
58540
+ const j2 = isGroupMoving ? false : this.smartJumpEndEdge();
58370
58541
  if (!j1 && !j2) {
58371
58542
  this.updatePaths();
58372
58543
  this.subject.publish(this);
@@ -58377,8 +58548,9 @@ var init_Connector = __esm(() => {
58377
58548
  const point5 = this.endPoint;
58378
58549
  if (point5.pointType !== "Board") {
58379
58550
  point5.recalculatePoint();
58380
- const j1 = this.smartJumpEndEdge();
58381
- const j2 = this.smartJumpStartEdge();
58551
+ const isGroupMoving = Group.movingGroupId !== null;
58552
+ const j1 = isGroupMoving ? false : this.smartJumpEndEdge();
58553
+ const j2 = isGroupMoving ? false : this.smartJumpStartEdge();
58382
58554
  if (!j1 && !j2) {
58383
58555
  this.updatePaths();
58384
58556
  this.subject.publish(this);
@@ -63691,172 +63863,6 @@ var init_Placeholder2 = __esm(() => {
63691
63863
  init_Placeholder();
63692
63864
  });
63693
63865
 
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
63866
  // src/Items/Group/index.ts
63861
63867
  var init_Group2 = __esm(() => {
63862
63868
  init_Group();
@@ -64306,26 +64312,18 @@ class ConnectorSnap {
64306
64312
  } else if (anchor) {
64307
64313
  this.controlPoint = getFixedPoint(item, anchor.getCenter());
64308
64314
  } else if (point5) {
64309
- this.controlPoint = getFixedPoint(item, point5.getCenter());
64315
+ const nearest2 = item.getNearestEdgePointTo(pointer);
64316
+ this.controlPoint = getFixedPoint(item, nearest2);
64310
64317
  } else {
64311
- this.controlPoint = getFixedPoint(item, pointer);
64318
+ if (this.hover.isTimeoutElapsed) {
64319
+ this.controlPoint = getFixedPoint(item, pointer);
64320
+ } else {
64321
+ this.controlPoint = getFixedPoint(item, pointer);
64322
+ }
64312
64323
  }
64313
64324
  }
64314
64325
  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
- }
64326
+ const hover = this.board.items.getUnderPointer(0)[0];
64329
64327
  if (hover) {
64330
64328
  if (hover !== this.hover.item) {
64331
64329
  this.hover = {
@@ -64382,18 +64380,8 @@ class ConnectorSnap {
64382
64380
  return nearest;
64383
64381
  }
64384
64382
  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);
64383
+ const nearestEdgePoint = item.getNearestEdgePointTo(position4);
64384
+ return getFixedPoint(item, nearestEdgePoint);
64397
64385
  }
64398
64386
  isNearBorder(item) {
64399
64387
  if (!item) {
@@ -64422,15 +64410,10 @@ class ConnectorSnap {
64422
64410
  }
64423
64411
  }
64424
64412
  setAnchors(item) {
64425
- const localPoints = item.getSnapAnchorPoints();
64426
- if (!localPoints) {
64413
+ const points = item.getSnapAnchorPoints();
64414
+ if (!points) {
64427
64415
  return;
64428
64416
  }
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
64417
  const anchors = [];
64435
64418
  for (const { x, y } of points) {
64436
64419
  anchors.push(new Anchor(x, y, 5, this.color.anchorBorder, this.color.anchorBackground, 1));
@@ -64464,19 +64447,9 @@ class ConnectorSnap {
64464
64447
  const { item, anchor } = this.snap;
64465
64448
  if (item) {
64466
64449
  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);
64450
+ const point5 = item.getNearestEdgePointTo(pointer);
64451
+ if (point5.getDistance(pointer) < this.distance.border || !this.hover.isTimeoutElapsed) {
64452
+ this.snap.point = new Anchor(point5.x, point5.y, 5, this.color.pointBorder, this.color.pointBackground, 1);
64480
64453
  } else {
64481
64454
  this.snap.point = null;
64482
64455
  }
@@ -64505,7 +64478,6 @@ class ConnectorSnap {
64505
64478
  }
64506
64479
  var init_ConnectorSnap = __esm(() => {
64507
64480
  init_ControlPoint();
64508
- init_BaseItem2();
64509
64481
  init_Anchor2();
64510
64482
  init_Connector();
64511
64483
  });