microboard-temp 0.14.2 → 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.
- package/dist/cjs/browser.js +192 -173
- package/dist/cjs/index.js +192 -173
- package/dist/cjs/node.js +192 -173
- package/dist/esm/browser.js +192 -173
- package/dist/esm/index.js +192 -173
- package/dist/esm/node.js +192 -173
- package/dist/types/Items/Group/Group.d.ts +6 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -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
|
|
58369
|
-
const
|
|
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
|
|
58381
|
-
const
|
|
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);
|
|
@@ -58392,14 +58564,19 @@ var init_Connector = __esm(() => {
|
|
|
58392
58564
|
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
58393
58565
|
return false;
|
|
58394
58566
|
const item = start.item;
|
|
58395
|
-
const
|
|
58396
|
-
if (!
|
|
58567
|
+
const localAnchors = item.getSnapAnchorPoints?.();
|
|
58568
|
+
if (!localAnchors || localAnchors.length === 0)
|
|
58397
58569
|
return false;
|
|
58570
|
+
const anchors = item instanceof BaseItem && item.parent !== "Board" ? localAnchors.map((a2) => {
|
|
58571
|
+
const p3 = a2.copy();
|
|
58572
|
+
item.getParentWorldMatrix().apply(p3);
|
|
58573
|
+
return p3;
|
|
58574
|
+
}) : localAnchors;
|
|
58398
58575
|
const EPS = 2;
|
|
58399
58576
|
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
58400
58577
|
if (!isOnAnchor)
|
|
58401
58578
|
return false;
|
|
58402
|
-
const center = item.getMbr().getCenter();
|
|
58579
|
+
const center = item instanceof BaseItem && item.parent !== "Board" ? item.getWorldMbr().getCenter() : item.getMbr().getCenter();
|
|
58403
58580
|
const dx = this.endPoint.x - center.x;
|
|
58404
58581
|
const dy = this.endPoint.y - center.y;
|
|
58405
58582
|
if (dx === 0 && dy === 0)
|
|
@@ -58430,14 +58607,19 @@ var init_Connector = __esm(() => {
|
|
|
58430
58607
|
if (end.pointType !== "Fixed" && end.pointType !== "Floating")
|
|
58431
58608
|
return false;
|
|
58432
58609
|
const item = end.item;
|
|
58433
|
-
const
|
|
58434
|
-
if (!
|
|
58610
|
+
const localAnchors = item.getSnapAnchorPoints?.();
|
|
58611
|
+
if (!localAnchors || localAnchors.length === 0)
|
|
58435
58612
|
return false;
|
|
58613
|
+
const anchors = item instanceof BaseItem && item.parent !== "Board" ? localAnchors.map((a2) => {
|
|
58614
|
+
const p3 = a2.copy();
|
|
58615
|
+
item.getParentWorldMatrix().apply(p3);
|
|
58616
|
+
return p3;
|
|
58617
|
+
}) : localAnchors;
|
|
58436
58618
|
const EPS = 2;
|
|
58437
58619
|
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
|
|
58438
58620
|
if (!isOnAnchor)
|
|
58439
58621
|
return false;
|
|
58440
|
-
const center = item.getMbr().getCenter();
|
|
58622
|
+
const center = item instanceof BaseItem && item.parent !== "Board" ? item.getWorldMbr().getCenter() : item.getMbr().getCenter();
|
|
58441
58623
|
const dx = this.startPoint.x - center.x;
|
|
58442
58624
|
const dy = this.startPoint.y - center.y;
|
|
58443
58625
|
if (dx === 0 && dy === 0)
|
|
@@ -63681,169 +63863,6 @@ var init_Placeholder2 = __esm(() => {
|
|
|
63681
63863
|
init_Placeholder();
|
|
63682
63864
|
});
|
|
63683
63865
|
|
|
63684
|
-
// src/Items/Group/Group.ts
|
|
63685
|
-
var Group;
|
|
63686
|
-
var init_Group = __esm(() => {
|
|
63687
|
-
init_Mbr();
|
|
63688
|
-
init_Point();
|
|
63689
|
-
init_BaseItem();
|
|
63690
|
-
Group = class Group extends BaseItem {
|
|
63691
|
-
events;
|
|
63692
|
-
itemType = "Group";
|
|
63693
|
-
parent = "Board";
|
|
63694
|
-
subject = new Subject;
|
|
63695
|
-
transformationRenderBlock = undefined;
|
|
63696
|
-
isLockedGroup = false;
|
|
63697
|
-
constructor(board, events, childIds = [], id = "") {
|
|
63698
|
-
super(board, id, undefined, true);
|
|
63699
|
-
this.events = events;
|
|
63700
|
-
this.canBeNested = true;
|
|
63701
|
-
if (childIds.length > 0) {
|
|
63702
|
-
this.applyAddChildren(childIds);
|
|
63703
|
-
}
|
|
63704
|
-
}
|
|
63705
|
-
isClosed() {
|
|
63706
|
-
return false;
|
|
63707
|
-
}
|
|
63708
|
-
getRichText() {
|
|
63709
|
-
return null;
|
|
63710
|
-
}
|
|
63711
|
-
apply(op) {
|
|
63712
|
-
switch (op.class) {
|
|
63713
|
-
case "Transformation":
|
|
63714
|
-
super.apply(op);
|
|
63715
|
-
this.updateMbr();
|
|
63716
|
-
break;
|
|
63717
|
-
case "Group":
|
|
63718
|
-
if (op.method === "addChild") {
|
|
63719
|
-
this.applyAddChildren([op.childId]);
|
|
63720
|
-
} else if (op.method === "removeChild") {
|
|
63721
|
-
this.applyRemoveChildren([op.childId]);
|
|
63722
|
-
} else {
|
|
63723
|
-
super.apply(op);
|
|
63724
|
-
}
|
|
63725
|
-
break;
|
|
63726
|
-
default:
|
|
63727
|
-
super.apply(op);
|
|
63728
|
-
return;
|
|
63729
|
-
}
|
|
63730
|
-
this.subject.publish(this);
|
|
63731
|
-
}
|
|
63732
|
-
emit(operation) {
|
|
63733
|
-
if (this.events) {
|
|
63734
|
-
const command = new GroupCommand([this], operation);
|
|
63735
|
-
command.apply();
|
|
63736
|
-
this.events.emit(operation, command);
|
|
63737
|
-
} else {
|
|
63738
|
-
this.apply(operation);
|
|
63739
|
-
}
|
|
63740
|
-
}
|
|
63741
|
-
setId(id) {
|
|
63742
|
-
this.id = id;
|
|
63743
|
-
this.transformation.setId(id);
|
|
63744
|
-
return this;
|
|
63745
|
-
}
|
|
63746
|
-
getMbr() {
|
|
63747
|
-
const children = this.index.listAll();
|
|
63748
|
-
if (children.length === 0) {
|
|
63749
|
-
return new Mbr(this.left, this.top, this.right, this.bottom);
|
|
63750
|
-
}
|
|
63751
|
-
const groupWorldMatrix = this.getWorldMatrix();
|
|
63752
|
-
let left = Number.MAX_SAFE_INTEGER;
|
|
63753
|
-
let top = Number.MAX_SAFE_INTEGER;
|
|
63754
|
-
let right = Number.MIN_SAFE_INTEGER;
|
|
63755
|
-
let bottom = Number.MIN_SAFE_INTEGER;
|
|
63756
|
-
for (const child of children) {
|
|
63757
|
-
const childLocalMbr = child.getMbr();
|
|
63758
|
-
const corners = [
|
|
63759
|
-
new Point(childLocalMbr.left, childLocalMbr.top),
|
|
63760
|
-
new Point(childLocalMbr.right, childLocalMbr.top),
|
|
63761
|
-
new Point(childLocalMbr.right, childLocalMbr.bottom),
|
|
63762
|
-
new Point(childLocalMbr.left, childLocalMbr.bottom)
|
|
63763
|
-
];
|
|
63764
|
-
for (const corner of corners) {
|
|
63765
|
-
groupWorldMatrix.apply(corner);
|
|
63766
|
-
if (corner.x < left)
|
|
63767
|
-
left = corner.x;
|
|
63768
|
-
if (corner.y < top)
|
|
63769
|
-
top = corner.y;
|
|
63770
|
-
if (corner.x > right)
|
|
63771
|
-
right = corner.x;
|
|
63772
|
-
if (corner.y > bottom)
|
|
63773
|
-
bottom = corner.y;
|
|
63774
|
-
}
|
|
63775
|
-
}
|
|
63776
|
-
const mbr = new Mbr(left, top, right, bottom);
|
|
63777
|
-
this.left = left;
|
|
63778
|
-
this.top = top;
|
|
63779
|
-
this.right = right;
|
|
63780
|
-
this.bottom = bottom;
|
|
63781
|
-
return mbr;
|
|
63782
|
-
}
|
|
63783
|
-
updateMbr() {
|
|
63784
|
-
this.getMbr();
|
|
63785
|
-
}
|
|
63786
|
-
getChildrenIds() {
|
|
63787
|
-
return this.index.listAll().map((item) => item.getId());
|
|
63788
|
-
}
|
|
63789
|
-
getChildren() {
|
|
63790
|
-
return this.index.listAll();
|
|
63791
|
-
}
|
|
63792
|
-
getLinkTo() {
|
|
63793
|
-
return this.linkTo.link;
|
|
63794
|
-
}
|
|
63795
|
-
serialize() {
|
|
63796
|
-
return {
|
|
63797
|
-
id: this.id,
|
|
63798
|
-
itemType: "Group",
|
|
63799
|
-
childIds: this.getChildrenIds(),
|
|
63800
|
-
transformation: this.transformation.serialize(),
|
|
63801
|
-
isLockedGroup: this.isLockedGroup
|
|
63802
|
-
};
|
|
63803
|
-
}
|
|
63804
|
-
deserialize(data) {
|
|
63805
|
-
if (data.transformation) {
|
|
63806
|
-
this.transformation.deserialize(data.transformation);
|
|
63807
|
-
}
|
|
63808
|
-
if (data.childIds && data.childIds.length > 0) {
|
|
63809
|
-
this.applyAddChildren(data.childIds);
|
|
63810
|
-
}
|
|
63811
|
-
if (data.isLockedGroup !== undefined) {
|
|
63812
|
-
this.isLockedGroup = data.isLockedGroup;
|
|
63813
|
-
}
|
|
63814
|
-
this.updateMbr();
|
|
63815
|
-
this.subject.publish(this);
|
|
63816
|
-
return this;
|
|
63817
|
-
}
|
|
63818
|
-
getId() {
|
|
63819
|
-
return this.id;
|
|
63820
|
-
}
|
|
63821
|
-
getIntersectionPoints(segment) {
|
|
63822
|
-
const lines = this.getMbr().getLines();
|
|
63823
|
-
const initPoints = [];
|
|
63824
|
-
return lines.reduce((acc, line) => {
|
|
63825
|
-
const intersections = line.getIntersectionPoints(segment);
|
|
63826
|
-
if (intersections.length > 0) {
|
|
63827
|
-
acc.push(...intersections);
|
|
63828
|
-
}
|
|
63829
|
-
return acc;
|
|
63830
|
-
}, initPoints);
|
|
63831
|
-
}
|
|
63832
|
-
render(context) {
|
|
63833
|
-
if (this.transformationRenderBlock) {
|
|
63834
|
-
return;
|
|
63835
|
-
}
|
|
63836
|
-
const ctx = context.ctx;
|
|
63837
|
-
ctx.save();
|
|
63838
|
-
this.transformation.applyToContext(ctx);
|
|
63839
|
-
for (const child of this.index.listAll()) {
|
|
63840
|
-
child.render(context);
|
|
63841
|
-
}
|
|
63842
|
-
ctx.restore();
|
|
63843
|
-
}
|
|
63844
|
-
};
|
|
63845
|
-
});
|
|
63846
|
-
|
|
63847
63866
|
// src/Items/Group/index.ts
|
|
63848
63867
|
var init_Group2 = __esm(() => {
|
|
63849
63868
|
init_Group();
|