microboard-temp 0.13.27 → 0.13.29
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 +43 -0
- package/dist/cjs/index.js +43 -0
- package/dist/cjs/node.js +43 -0
- package/dist/esm/browser.js +43 -0
- package/dist/esm/index.js +43 -0
- package/dist/esm/node.js +43 -0
- package/dist/types/Items/Connector/Connector.d.ts +6 -0
- package/dist/types/Items/Connector/ControlPoint.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -36852,6 +36852,9 @@ class FloatingPoint extends Point {
|
|
|
36852
36852
|
relativePoint;
|
|
36853
36853
|
pointType = "Floating";
|
|
36854
36854
|
edge;
|
|
36855
|
+
getEdge() {
|
|
36856
|
+
return this.edge;
|
|
36857
|
+
}
|
|
36855
36858
|
constructor(item, relativePoint) {
|
|
36856
36859
|
super();
|
|
36857
36860
|
this.item = item;
|
|
@@ -36893,6 +36896,9 @@ class FixedPoint extends Point {
|
|
|
36893
36896
|
relativePoint;
|
|
36894
36897
|
pointType = "Fixed";
|
|
36895
36898
|
edge;
|
|
36899
|
+
getEdge() {
|
|
36900
|
+
return this.edge;
|
|
36901
|
+
}
|
|
36896
36902
|
constructor(item, relativePoint) {
|
|
36897
36903
|
super();
|
|
36898
36904
|
this.item = item;
|
|
@@ -37806,6 +37812,7 @@ class Connector2 extends BaseItem {
|
|
|
37806
37812
|
const point5 = this.startPoint;
|
|
37807
37813
|
if (point5.pointType !== "Board") {
|
|
37808
37814
|
point5.recalculatePoint();
|
|
37815
|
+
this.smartJumpStartEdge();
|
|
37809
37816
|
this.updatePaths();
|
|
37810
37817
|
this.subject.publish(this);
|
|
37811
37818
|
}
|
|
@@ -37814,10 +37821,46 @@ class Connector2 extends BaseItem {
|
|
|
37814
37821
|
const point5 = this.endPoint;
|
|
37815
37822
|
if (point5.pointType !== "Board") {
|
|
37816
37823
|
point5.recalculatePoint();
|
|
37824
|
+
this.smartJumpStartEdge();
|
|
37817
37825
|
this.updatePaths();
|
|
37818
37826
|
this.subject.publish(this);
|
|
37819
37827
|
}
|
|
37820
37828
|
};
|
|
37829
|
+
smartJumpStartEdge() {
|
|
37830
|
+
const start = this.startPoint;
|
|
37831
|
+
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
37832
|
+
return;
|
|
37833
|
+
const item = start.item;
|
|
37834
|
+
const anchors = item.getSnapAnchorPoints?.();
|
|
37835
|
+
if (!anchors || anchors.length === 0)
|
|
37836
|
+
return;
|
|
37837
|
+
const EPS = 2;
|
|
37838
|
+
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
37839
|
+
if (!isOnAnchor)
|
|
37840
|
+
return;
|
|
37841
|
+
const center = item.getMbr().getCenter();
|
|
37842
|
+
const dx = this.endPoint.x - center.x;
|
|
37843
|
+
const dy = this.endPoint.y - center.y;
|
|
37844
|
+
if (dx === 0 && dy === 0)
|
|
37845
|
+
return;
|
|
37846
|
+
let best = anchors[0];
|
|
37847
|
+
let bestDot = -Infinity;
|
|
37848
|
+
for (const anchor of anchors) {
|
|
37849
|
+
const ax = anchor.x - center.x;
|
|
37850
|
+
const ay = anchor.y - center.y;
|
|
37851
|
+
const len = Math.sqrt(ax * ax + ay * ay);
|
|
37852
|
+
if (len === 0)
|
|
37853
|
+
continue;
|
|
37854
|
+
const dot = (ax * dx + ay * dy) / len;
|
|
37855
|
+
if (dot > bestDot) {
|
|
37856
|
+
bestDot = dot;
|
|
37857
|
+
best = anchor;
|
|
37858
|
+
}
|
|
37859
|
+
}
|
|
37860
|
+
if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
|
|
37861
|
+
return;
|
|
37862
|
+
this.startPoint = new FixedPoint(item, toRelativePoint(best, item));
|
|
37863
|
+
}
|
|
37821
37864
|
clearObservedItems() {
|
|
37822
37865
|
const startPoint = this.getStartPoint();
|
|
37823
37866
|
const endPoint = this.getEndPoint();
|
package/dist/cjs/index.js
CHANGED
|
@@ -36852,6 +36852,9 @@ class FloatingPoint extends Point {
|
|
|
36852
36852
|
relativePoint;
|
|
36853
36853
|
pointType = "Floating";
|
|
36854
36854
|
edge;
|
|
36855
|
+
getEdge() {
|
|
36856
|
+
return this.edge;
|
|
36857
|
+
}
|
|
36855
36858
|
constructor(item, relativePoint) {
|
|
36856
36859
|
super();
|
|
36857
36860
|
this.item = item;
|
|
@@ -36893,6 +36896,9 @@ class FixedPoint extends Point {
|
|
|
36893
36896
|
relativePoint;
|
|
36894
36897
|
pointType = "Fixed";
|
|
36895
36898
|
edge;
|
|
36899
|
+
getEdge() {
|
|
36900
|
+
return this.edge;
|
|
36901
|
+
}
|
|
36896
36902
|
constructor(item, relativePoint) {
|
|
36897
36903
|
super();
|
|
36898
36904
|
this.item = item;
|
|
@@ -37806,6 +37812,7 @@ class Connector2 extends BaseItem {
|
|
|
37806
37812
|
const point5 = this.startPoint;
|
|
37807
37813
|
if (point5.pointType !== "Board") {
|
|
37808
37814
|
point5.recalculatePoint();
|
|
37815
|
+
this.smartJumpStartEdge();
|
|
37809
37816
|
this.updatePaths();
|
|
37810
37817
|
this.subject.publish(this);
|
|
37811
37818
|
}
|
|
@@ -37814,10 +37821,46 @@ class Connector2 extends BaseItem {
|
|
|
37814
37821
|
const point5 = this.endPoint;
|
|
37815
37822
|
if (point5.pointType !== "Board") {
|
|
37816
37823
|
point5.recalculatePoint();
|
|
37824
|
+
this.smartJumpStartEdge();
|
|
37817
37825
|
this.updatePaths();
|
|
37818
37826
|
this.subject.publish(this);
|
|
37819
37827
|
}
|
|
37820
37828
|
};
|
|
37829
|
+
smartJumpStartEdge() {
|
|
37830
|
+
const start = this.startPoint;
|
|
37831
|
+
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
37832
|
+
return;
|
|
37833
|
+
const item = start.item;
|
|
37834
|
+
const anchors = item.getSnapAnchorPoints?.();
|
|
37835
|
+
if (!anchors || anchors.length === 0)
|
|
37836
|
+
return;
|
|
37837
|
+
const EPS = 2;
|
|
37838
|
+
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
37839
|
+
if (!isOnAnchor)
|
|
37840
|
+
return;
|
|
37841
|
+
const center = item.getMbr().getCenter();
|
|
37842
|
+
const dx = this.endPoint.x - center.x;
|
|
37843
|
+
const dy = this.endPoint.y - center.y;
|
|
37844
|
+
if (dx === 0 && dy === 0)
|
|
37845
|
+
return;
|
|
37846
|
+
let best = anchors[0];
|
|
37847
|
+
let bestDot = -Infinity;
|
|
37848
|
+
for (const anchor of anchors) {
|
|
37849
|
+
const ax = anchor.x - center.x;
|
|
37850
|
+
const ay = anchor.y - center.y;
|
|
37851
|
+
const len = Math.sqrt(ax * ax + ay * ay);
|
|
37852
|
+
if (len === 0)
|
|
37853
|
+
continue;
|
|
37854
|
+
const dot = (ax * dx + ay * dy) / len;
|
|
37855
|
+
if (dot > bestDot) {
|
|
37856
|
+
bestDot = dot;
|
|
37857
|
+
best = anchor;
|
|
37858
|
+
}
|
|
37859
|
+
}
|
|
37860
|
+
if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
|
|
37861
|
+
return;
|
|
37862
|
+
this.startPoint = new FixedPoint(item, toRelativePoint(best, item));
|
|
37863
|
+
}
|
|
37821
37864
|
clearObservedItems() {
|
|
37822
37865
|
const startPoint = this.getStartPoint();
|
|
37823
37866
|
const endPoint = this.getEndPoint();
|
package/dist/cjs/node.js
CHANGED
|
@@ -39325,6 +39325,9 @@ class FloatingPoint extends Point {
|
|
|
39325
39325
|
relativePoint;
|
|
39326
39326
|
pointType = "Floating";
|
|
39327
39327
|
edge;
|
|
39328
|
+
getEdge() {
|
|
39329
|
+
return this.edge;
|
|
39330
|
+
}
|
|
39328
39331
|
constructor(item, relativePoint) {
|
|
39329
39332
|
super();
|
|
39330
39333
|
this.item = item;
|
|
@@ -39366,6 +39369,9 @@ class FixedPoint extends Point {
|
|
|
39366
39369
|
relativePoint;
|
|
39367
39370
|
pointType = "Fixed";
|
|
39368
39371
|
edge;
|
|
39372
|
+
getEdge() {
|
|
39373
|
+
return this.edge;
|
|
39374
|
+
}
|
|
39369
39375
|
constructor(item, relativePoint) {
|
|
39370
39376
|
super();
|
|
39371
39377
|
this.item = item;
|
|
@@ -40279,6 +40285,7 @@ class Connector2 extends BaseItem {
|
|
|
40279
40285
|
const point5 = this.startPoint;
|
|
40280
40286
|
if (point5.pointType !== "Board") {
|
|
40281
40287
|
point5.recalculatePoint();
|
|
40288
|
+
this.smartJumpStartEdge();
|
|
40282
40289
|
this.updatePaths();
|
|
40283
40290
|
this.subject.publish(this);
|
|
40284
40291
|
}
|
|
@@ -40287,10 +40294,46 @@ class Connector2 extends BaseItem {
|
|
|
40287
40294
|
const point5 = this.endPoint;
|
|
40288
40295
|
if (point5.pointType !== "Board") {
|
|
40289
40296
|
point5.recalculatePoint();
|
|
40297
|
+
this.smartJumpStartEdge();
|
|
40290
40298
|
this.updatePaths();
|
|
40291
40299
|
this.subject.publish(this);
|
|
40292
40300
|
}
|
|
40293
40301
|
};
|
|
40302
|
+
smartJumpStartEdge() {
|
|
40303
|
+
const start = this.startPoint;
|
|
40304
|
+
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
40305
|
+
return;
|
|
40306
|
+
const item = start.item;
|
|
40307
|
+
const anchors = item.getSnapAnchorPoints?.();
|
|
40308
|
+
if (!anchors || anchors.length === 0)
|
|
40309
|
+
return;
|
|
40310
|
+
const EPS = 2;
|
|
40311
|
+
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
40312
|
+
if (!isOnAnchor)
|
|
40313
|
+
return;
|
|
40314
|
+
const center = item.getMbr().getCenter();
|
|
40315
|
+
const dx = this.endPoint.x - center.x;
|
|
40316
|
+
const dy = this.endPoint.y - center.y;
|
|
40317
|
+
if (dx === 0 && dy === 0)
|
|
40318
|
+
return;
|
|
40319
|
+
let best = anchors[0];
|
|
40320
|
+
let bestDot = -Infinity;
|
|
40321
|
+
for (const anchor of anchors) {
|
|
40322
|
+
const ax = anchor.x - center.x;
|
|
40323
|
+
const ay = anchor.y - center.y;
|
|
40324
|
+
const len = Math.sqrt(ax * ax + ay * ay);
|
|
40325
|
+
if (len === 0)
|
|
40326
|
+
continue;
|
|
40327
|
+
const dot = (ax * dx + ay * dy) / len;
|
|
40328
|
+
if (dot > bestDot) {
|
|
40329
|
+
bestDot = dot;
|
|
40330
|
+
best = anchor;
|
|
40331
|
+
}
|
|
40332
|
+
}
|
|
40333
|
+
if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
|
|
40334
|
+
return;
|
|
40335
|
+
this.startPoint = new FixedPoint(item, toRelativePoint(best, item));
|
|
40336
|
+
}
|
|
40294
40337
|
clearObservedItems() {
|
|
40295
40338
|
const startPoint = this.getStartPoint();
|
|
40296
40339
|
const endPoint = this.getEndPoint();
|
package/dist/esm/browser.js
CHANGED
|
@@ -36681,6 +36681,9 @@ class FloatingPoint extends Point {
|
|
|
36681
36681
|
relativePoint;
|
|
36682
36682
|
pointType = "Floating";
|
|
36683
36683
|
edge;
|
|
36684
|
+
getEdge() {
|
|
36685
|
+
return this.edge;
|
|
36686
|
+
}
|
|
36684
36687
|
constructor(item, relativePoint) {
|
|
36685
36688
|
super();
|
|
36686
36689
|
this.item = item;
|
|
@@ -36722,6 +36725,9 @@ class FixedPoint extends Point {
|
|
|
36722
36725
|
relativePoint;
|
|
36723
36726
|
pointType = "Fixed";
|
|
36724
36727
|
edge;
|
|
36728
|
+
getEdge() {
|
|
36729
|
+
return this.edge;
|
|
36730
|
+
}
|
|
36725
36731
|
constructor(item, relativePoint) {
|
|
36726
36732
|
super();
|
|
36727
36733
|
this.item = item;
|
|
@@ -37635,6 +37641,7 @@ class Connector2 extends BaseItem {
|
|
|
37635
37641
|
const point5 = this.startPoint;
|
|
37636
37642
|
if (point5.pointType !== "Board") {
|
|
37637
37643
|
point5.recalculatePoint();
|
|
37644
|
+
this.smartJumpStartEdge();
|
|
37638
37645
|
this.updatePaths();
|
|
37639
37646
|
this.subject.publish(this);
|
|
37640
37647
|
}
|
|
@@ -37643,10 +37650,46 @@ class Connector2 extends BaseItem {
|
|
|
37643
37650
|
const point5 = this.endPoint;
|
|
37644
37651
|
if (point5.pointType !== "Board") {
|
|
37645
37652
|
point5.recalculatePoint();
|
|
37653
|
+
this.smartJumpStartEdge();
|
|
37646
37654
|
this.updatePaths();
|
|
37647
37655
|
this.subject.publish(this);
|
|
37648
37656
|
}
|
|
37649
37657
|
};
|
|
37658
|
+
smartJumpStartEdge() {
|
|
37659
|
+
const start = this.startPoint;
|
|
37660
|
+
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
37661
|
+
return;
|
|
37662
|
+
const item = start.item;
|
|
37663
|
+
const anchors = item.getSnapAnchorPoints?.();
|
|
37664
|
+
if (!anchors || anchors.length === 0)
|
|
37665
|
+
return;
|
|
37666
|
+
const EPS = 2;
|
|
37667
|
+
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
37668
|
+
if (!isOnAnchor)
|
|
37669
|
+
return;
|
|
37670
|
+
const center = item.getMbr().getCenter();
|
|
37671
|
+
const dx = this.endPoint.x - center.x;
|
|
37672
|
+
const dy = this.endPoint.y - center.y;
|
|
37673
|
+
if (dx === 0 && dy === 0)
|
|
37674
|
+
return;
|
|
37675
|
+
let best = anchors[0];
|
|
37676
|
+
let bestDot = -Infinity;
|
|
37677
|
+
for (const anchor of anchors) {
|
|
37678
|
+
const ax = anchor.x - center.x;
|
|
37679
|
+
const ay = anchor.y - center.y;
|
|
37680
|
+
const len = Math.sqrt(ax * ax + ay * ay);
|
|
37681
|
+
if (len === 0)
|
|
37682
|
+
continue;
|
|
37683
|
+
const dot = (ax * dx + ay * dy) / len;
|
|
37684
|
+
if (dot > bestDot) {
|
|
37685
|
+
bestDot = dot;
|
|
37686
|
+
best = anchor;
|
|
37687
|
+
}
|
|
37688
|
+
}
|
|
37689
|
+
if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
|
|
37690
|
+
return;
|
|
37691
|
+
this.startPoint = new FixedPoint(item, toRelativePoint(best, item));
|
|
37692
|
+
}
|
|
37650
37693
|
clearObservedItems() {
|
|
37651
37694
|
const startPoint = this.getStartPoint();
|
|
37652
37695
|
const endPoint = this.getEndPoint();
|
package/dist/esm/index.js
CHANGED
|
@@ -36674,6 +36674,9 @@ class FloatingPoint extends Point {
|
|
|
36674
36674
|
relativePoint;
|
|
36675
36675
|
pointType = "Floating";
|
|
36676
36676
|
edge;
|
|
36677
|
+
getEdge() {
|
|
36678
|
+
return this.edge;
|
|
36679
|
+
}
|
|
36677
36680
|
constructor(item, relativePoint) {
|
|
36678
36681
|
super();
|
|
36679
36682
|
this.item = item;
|
|
@@ -36715,6 +36718,9 @@ class FixedPoint extends Point {
|
|
|
36715
36718
|
relativePoint;
|
|
36716
36719
|
pointType = "Fixed";
|
|
36717
36720
|
edge;
|
|
36721
|
+
getEdge() {
|
|
36722
|
+
return this.edge;
|
|
36723
|
+
}
|
|
36718
36724
|
constructor(item, relativePoint) {
|
|
36719
36725
|
super();
|
|
36720
36726
|
this.item = item;
|
|
@@ -37628,6 +37634,7 @@ class Connector2 extends BaseItem {
|
|
|
37628
37634
|
const point5 = this.startPoint;
|
|
37629
37635
|
if (point5.pointType !== "Board") {
|
|
37630
37636
|
point5.recalculatePoint();
|
|
37637
|
+
this.smartJumpStartEdge();
|
|
37631
37638
|
this.updatePaths();
|
|
37632
37639
|
this.subject.publish(this);
|
|
37633
37640
|
}
|
|
@@ -37636,10 +37643,46 @@ class Connector2 extends BaseItem {
|
|
|
37636
37643
|
const point5 = this.endPoint;
|
|
37637
37644
|
if (point5.pointType !== "Board") {
|
|
37638
37645
|
point5.recalculatePoint();
|
|
37646
|
+
this.smartJumpStartEdge();
|
|
37639
37647
|
this.updatePaths();
|
|
37640
37648
|
this.subject.publish(this);
|
|
37641
37649
|
}
|
|
37642
37650
|
};
|
|
37651
|
+
smartJumpStartEdge() {
|
|
37652
|
+
const start = this.startPoint;
|
|
37653
|
+
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
37654
|
+
return;
|
|
37655
|
+
const item = start.item;
|
|
37656
|
+
const anchors = item.getSnapAnchorPoints?.();
|
|
37657
|
+
if (!anchors || anchors.length === 0)
|
|
37658
|
+
return;
|
|
37659
|
+
const EPS = 2;
|
|
37660
|
+
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
37661
|
+
if (!isOnAnchor)
|
|
37662
|
+
return;
|
|
37663
|
+
const center = item.getMbr().getCenter();
|
|
37664
|
+
const dx = this.endPoint.x - center.x;
|
|
37665
|
+
const dy = this.endPoint.y - center.y;
|
|
37666
|
+
if (dx === 0 && dy === 0)
|
|
37667
|
+
return;
|
|
37668
|
+
let best = anchors[0];
|
|
37669
|
+
let bestDot = -Infinity;
|
|
37670
|
+
for (const anchor of anchors) {
|
|
37671
|
+
const ax = anchor.x - center.x;
|
|
37672
|
+
const ay = anchor.y - center.y;
|
|
37673
|
+
const len = Math.sqrt(ax * ax + ay * ay);
|
|
37674
|
+
if (len === 0)
|
|
37675
|
+
continue;
|
|
37676
|
+
const dot = (ax * dx + ay * dy) / len;
|
|
37677
|
+
if (dot > bestDot) {
|
|
37678
|
+
bestDot = dot;
|
|
37679
|
+
best = anchor;
|
|
37680
|
+
}
|
|
37681
|
+
}
|
|
37682
|
+
if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
|
|
37683
|
+
return;
|
|
37684
|
+
this.startPoint = new FixedPoint(item, toRelativePoint(best, item));
|
|
37685
|
+
}
|
|
37643
37686
|
clearObservedItems() {
|
|
37644
37687
|
const startPoint = this.getStartPoint();
|
|
37645
37688
|
const endPoint = this.getEndPoint();
|
package/dist/esm/node.js
CHANGED
|
@@ -39142,6 +39142,9 @@ class FloatingPoint extends Point {
|
|
|
39142
39142
|
relativePoint;
|
|
39143
39143
|
pointType = "Floating";
|
|
39144
39144
|
edge;
|
|
39145
|
+
getEdge() {
|
|
39146
|
+
return this.edge;
|
|
39147
|
+
}
|
|
39145
39148
|
constructor(item, relativePoint) {
|
|
39146
39149
|
super();
|
|
39147
39150
|
this.item = item;
|
|
@@ -39183,6 +39186,9 @@ class FixedPoint extends Point {
|
|
|
39183
39186
|
relativePoint;
|
|
39184
39187
|
pointType = "Fixed";
|
|
39185
39188
|
edge;
|
|
39189
|
+
getEdge() {
|
|
39190
|
+
return this.edge;
|
|
39191
|
+
}
|
|
39186
39192
|
constructor(item, relativePoint) {
|
|
39187
39193
|
super();
|
|
39188
39194
|
this.item = item;
|
|
@@ -40096,6 +40102,7 @@ class Connector2 extends BaseItem {
|
|
|
40096
40102
|
const point5 = this.startPoint;
|
|
40097
40103
|
if (point5.pointType !== "Board") {
|
|
40098
40104
|
point5.recalculatePoint();
|
|
40105
|
+
this.smartJumpStartEdge();
|
|
40099
40106
|
this.updatePaths();
|
|
40100
40107
|
this.subject.publish(this);
|
|
40101
40108
|
}
|
|
@@ -40104,10 +40111,46 @@ class Connector2 extends BaseItem {
|
|
|
40104
40111
|
const point5 = this.endPoint;
|
|
40105
40112
|
if (point5.pointType !== "Board") {
|
|
40106
40113
|
point5.recalculatePoint();
|
|
40114
|
+
this.smartJumpStartEdge();
|
|
40107
40115
|
this.updatePaths();
|
|
40108
40116
|
this.subject.publish(this);
|
|
40109
40117
|
}
|
|
40110
40118
|
};
|
|
40119
|
+
smartJumpStartEdge() {
|
|
40120
|
+
const start = this.startPoint;
|
|
40121
|
+
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
40122
|
+
return;
|
|
40123
|
+
const item = start.item;
|
|
40124
|
+
const anchors = item.getSnapAnchorPoints?.();
|
|
40125
|
+
if (!anchors || anchors.length === 0)
|
|
40126
|
+
return;
|
|
40127
|
+
const EPS = 2;
|
|
40128
|
+
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
40129
|
+
if (!isOnAnchor)
|
|
40130
|
+
return;
|
|
40131
|
+
const center = item.getMbr().getCenter();
|
|
40132
|
+
const dx = this.endPoint.x - center.x;
|
|
40133
|
+
const dy = this.endPoint.y - center.y;
|
|
40134
|
+
if (dx === 0 && dy === 0)
|
|
40135
|
+
return;
|
|
40136
|
+
let best = anchors[0];
|
|
40137
|
+
let bestDot = -Infinity;
|
|
40138
|
+
for (const anchor of anchors) {
|
|
40139
|
+
const ax = anchor.x - center.x;
|
|
40140
|
+
const ay = anchor.y - center.y;
|
|
40141
|
+
const len = Math.sqrt(ax * ax + ay * ay);
|
|
40142
|
+
if (len === 0)
|
|
40143
|
+
continue;
|
|
40144
|
+
const dot = (ax * dx + ay * dy) / len;
|
|
40145
|
+
if (dot > bestDot) {
|
|
40146
|
+
bestDot = dot;
|
|
40147
|
+
best = anchor;
|
|
40148
|
+
}
|
|
40149
|
+
}
|
|
40150
|
+
if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
|
|
40151
|
+
return;
|
|
40152
|
+
this.startPoint = new FixedPoint(item, toRelativePoint(best, item));
|
|
40153
|
+
}
|
|
40111
40154
|
clearObservedItems() {
|
|
40112
40155
|
const startPoint = this.getStartPoint();
|
|
40113
40156
|
const endPoint = this.getEndPoint();
|
|
@@ -57,6 +57,12 @@ export declare class Connector extends BaseItem {
|
|
|
57
57
|
private initText;
|
|
58
58
|
observerStartPointItem: () => void;
|
|
59
59
|
observerEndPointItem: () => void;
|
|
60
|
+
/**
|
|
61
|
+
* If the start point is attached to one of the 4 edge-center anchors, re-evaluate
|
|
62
|
+
* which edge best faces the current end position and jump there to avoid sharp bends.
|
|
63
|
+
* Purely local/visual — no operation is emitted.
|
|
64
|
+
*/
|
|
65
|
+
private smartJumpStartEdge;
|
|
60
66
|
clearObservedItems(): void;
|
|
61
67
|
private unsubscribeFromItem;
|
|
62
68
|
private subscribeToItem;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Point } from "../Point";
|
|
2
2
|
import { Item } from "../Item";
|
|
3
3
|
import { Connector } from "./Connector";
|
|
4
|
+
export type Edge = "top" | "bottom" | "left" | "right";
|
|
4
5
|
export interface BoardPointData {
|
|
5
6
|
pointType: "Board";
|
|
6
7
|
x: number;
|
|
@@ -35,6 +36,7 @@ export declare class FloatingPoint extends Point {
|
|
|
35
36
|
readonly relativePoint: Point;
|
|
36
37
|
readonly pointType = "Floating";
|
|
37
38
|
private edge;
|
|
39
|
+
getEdge(): Edge | undefined;
|
|
38
40
|
constructor(item: Item, relativePoint: Point);
|
|
39
41
|
recalculatePoint(): void;
|
|
40
42
|
serialize(): FloatingPointData;
|
|
@@ -45,6 +47,7 @@ export declare class FixedPoint extends Point {
|
|
|
45
47
|
readonly relativePoint: Point;
|
|
46
48
|
readonly pointType = "Fixed";
|
|
47
49
|
private edge;
|
|
50
|
+
getEdge(): Edge | undefined;
|
|
48
51
|
constructor(item: Item, relativePoint: Point);
|
|
49
52
|
recalculatePoint(): void;
|
|
50
53
|
serialize(): FixedPointData;
|