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/esm/index.js
CHANGED
|
@@ -58098,6 +58098,175 @@ var init_getLine = __esm(() => {
|
|
|
58098
58098
|
init_getStraightLine();
|
|
58099
58099
|
});
|
|
58100
58100
|
|
|
58101
|
+
// src/Items/Group/Group.ts
|
|
58102
|
+
var Group;
|
|
58103
|
+
var init_Group = __esm(() => {
|
|
58104
|
+
init_Mbr();
|
|
58105
|
+
init_Point();
|
|
58106
|
+
init_BaseItem();
|
|
58107
|
+
Group = class Group extends BaseItem {
|
|
58108
|
+
events;
|
|
58109
|
+
itemType = "Group";
|
|
58110
|
+
parent = "Board";
|
|
58111
|
+
subject = new Subject;
|
|
58112
|
+
transformationRenderBlock = undefined;
|
|
58113
|
+
isLockedGroup = false;
|
|
58114
|
+
static movingGroupId = null;
|
|
58115
|
+
constructor(board, events, childIds = [], id = "") {
|
|
58116
|
+
super(board, id, undefined, true);
|
|
58117
|
+
this.events = events;
|
|
58118
|
+
this.canBeNested = true;
|
|
58119
|
+
if (childIds.length > 0) {
|
|
58120
|
+
this.applyAddChildren(childIds);
|
|
58121
|
+
}
|
|
58122
|
+
}
|
|
58123
|
+
isClosed() {
|
|
58124
|
+
return false;
|
|
58125
|
+
}
|
|
58126
|
+
getRichText() {
|
|
58127
|
+
return null;
|
|
58128
|
+
}
|
|
58129
|
+
apply(op) {
|
|
58130
|
+
switch (op.class) {
|
|
58131
|
+
case "Transformation":
|
|
58132
|
+
super.apply(op);
|
|
58133
|
+
this.updateMbr();
|
|
58134
|
+
Group.movingGroupId = this.id;
|
|
58135
|
+
for (const child of this.index.listAll()) {
|
|
58136
|
+
child.subject.publish(child);
|
|
58137
|
+
}
|
|
58138
|
+
Group.movingGroupId = null;
|
|
58139
|
+
break;
|
|
58140
|
+
case "Group":
|
|
58141
|
+
if (op.method === "addChild") {
|
|
58142
|
+
this.applyAddChildren([op.childId]);
|
|
58143
|
+
} else if (op.method === "removeChild") {
|
|
58144
|
+
this.applyRemoveChildren([op.childId]);
|
|
58145
|
+
} else {
|
|
58146
|
+
super.apply(op);
|
|
58147
|
+
}
|
|
58148
|
+
break;
|
|
58149
|
+
default:
|
|
58150
|
+
super.apply(op);
|
|
58151
|
+
return;
|
|
58152
|
+
}
|
|
58153
|
+
this.subject.publish(this);
|
|
58154
|
+
}
|
|
58155
|
+
emit(operation) {
|
|
58156
|
+
if (this.events) {
|
|
58157
|
+
const command = new GroupCommand([this], operation);
|
|
58158
|
+
command.apply();
|
|
58159
|
+
this.events.emit(operation, command);
|
|
58160
|
+
} else {
|
|
58161
|
+
this.apply(operation);
|
|
58162
|
+
}
|
|
58163
|
+
}
|
|
58164
|
+
setId(id) {
|
|
58165
|
+
this.id = id;
|
|
58166
|
+
this.transformation.setId(id);
|
|
58167
|
+
return this;
|
|
58168
|
+
}
|
|
58169
|
+
getMbr() {
|
|
58170
|
+
const children = this.index.listAll();
|
|
58171
|
+
if (children.length === 0) {
|
|
58172
|
+
return new Mbr(this.left, this.top, this.right, this.bottom);
|
|
58173
|
+
}
|
|
58174
|
+
const groupWorldMatrix = this.getWorldMatrix();
|
|
58175
|
+
let left = Number.MAX_SAFE_INTEGER;
|
|
58176
|
+
let top = Number.MAX_SAFE_INTEGER;
|
|
58177
|
+
let right = Number.MIN_SAFE_INTEGER;
|
|
58178
|
+
let bottom = Number.MIN_SAFE_INTEGER;
|
|
58179
|
+
for (const child of children) {
|
|
58180
|
+
const childLocalMbr = child.getMbr();
|
|
58181
|
+
const corners = [
|
|
58182
|
+
new Point(childLocalMbr.left, childLocalMbr.top),
|
|
58183
|
+
new Point(childLocalMbr.right, childLocalMbr.top),
|
|
58184
|
+
new Point(childLocalMbr.right, childLocalMbr.bottom),
|
|
58185
|
+
new Point(childLocalMbr.left, childLocalMbr.bottom)
|
|
58186
|
+
];
|
|
58187
|
+
for (const corner of corners) {
|
|
58188
|
+
groupWorldMatrix.apply(corner);
|
|
58189
|
+
if (corner.x < left)
|
|
58190
|
+
left = corner.x;
|
|
58191
|
+
if (corner.y < top)
|
|
58192
|
+
top = corner.y;
|
|
58193
|
+
if (corner.x > right)
|
|
58194
|
+
right = corner.x;
|
|
58195
|
+
if (corner.y > bottom)
|
|
58196
|
+
bottom = corner.y;
|
|
58197
|
+
}
|
|
58198
|
+
}
|
|
58199
|
+
const mbr = new Mbr(left, top, right, bottom);
|
|
58200
|
+
this.left = left;
|
|
58201
|
+
this.top = top;
|
|
58202
|
+
this.right = right;
|
|
58203
|
+
this.bottom = bottom;
|
|
58204
|
+
return mbr;
|
|
58205
|
+
}
|
|
58206
|
+
updateMbr() {
|
|
58207
|
+
this.getMbr();
|
|
58208
|
+
}
|
|
58209
|
+
getChildrenIds() {
|
|
58210
|
+
return this.index.listAll().map((item) => item.getId());
|
|
58211
|
+
}
|
|
58212
|
+
getChildren() {
|
|
58213
|
+
return this.index.listAll();
|
|
58214
|
+
}
|
|
58215
|
+
getLinkTo() {
|
|
58216
|
+
return this.linkTo.link;
|
|
58217
|
+
}
|
|
58218
|
+
serialize() {
|
|
58219
|
+
return {
|
|
58220
|
+
id: this.id,
|
|
58221
|
+
itemType: "Group",
|
|
58222
|
+
childIds: this.getChildrenIds(),
|
|
58223
|
+
transformation: this.transformation.serialize(),
|
|
58224
|
+
isLockedGroup: this.isLockedGroup
|
|
58225
|
+
};
|
|
58226
|
+
}
|
|
58227
|
+
deserialize(data) {
|
|
58228
|
+
if (data.transformation) {
|
|
58229
|
+
this.transformation.deserialize(data.transformation);
|
|
58230
|
+
}
|
|
58231
|
+
if (data.childIds && data.childIds.length > 0) {
|
|
58232
|
+
this.applyAddChildren(data.childIds);
|
|
58233
|
+
}
|
|
58234
|
+
if (data.isLockedGroup !== undefined) {
|
|
58235
|
+
this.isLockedGroup = data.isLockedGroup;
|
|
58236
|
+
}
|
|
58237
|
+
this.updateMbr();
|
|
58238
|
+
this.subject.publish(this);
|
|
58239
|
+
return this;
|
|
58240
|
+
}
|
|
58241
|
+
getId() {
|
|
58242
|
+
return this.id;
|
|
58243
|
+
}
|
|
58244
|
+
getIntersectionPoints(segment) {
|
|
58245
|
+
const lines = this.getMbr().getLines();
|
|
58246
|
+
const initPoints = [];
|
|
58247
|
+
return lines.reduce((acc, line) => {
|
|
58248
|
+
const intersections = line.getIntersectionPoints(segment);
|
|
58249
|
+
if (intersections.length > 0) {
|
|
58250
|
+
acc.push(...intersections);
|
|
58251
|
+
}
|
|
58252
|
+
return acc;
|
|
58253
|
+
}, initPoints);
|
|
58254
|
+
}
|
|
58255
|
+
render(context) {
|
|
58256
|
+
if (this.transformationRenderBlock) {
|
|
58257
|
+
return;
|
|
58258
|
+
}
|
|
58259
|
+
const ctx = context.ctx;
|
|
58260
|
+
ctx.save();
|
|
58261
|
+
this.transformation.applyToContext(ctx);
|
|
58262
|
+
for (const child of this.index.listAll()) {
|
|
58263
|
+
child.render(context);
|
|
58264
|
+
}
|
|
58265
|
+
ctx.restore();
|
|
58266
|
+
}
|
|
58267
|
+
};
|
|
58268
|
+
});
|
|
58269
|
+
|
|
58101
58270
|
// src/Items/Connector/ConnectorTypes.ts
|
|
58102
58271
|
var ConnectionLineWidths, CONNECTOR_COLOR = "rgb(20, 21, 26)", CONNECTOR_LINE_WIDTH = 1, CONNECTOR_BORDER_STYLE = "solid", DEFAULT_END_POINTER = "TriangleFilled", CONNECTOR_POINTER_TYPES;
|
|
58103
58272
|
var init_ConnectorTypes = __esm(() => {
|
|
@@ -58206,6 +58375,7 @@ var init_Connector = __esm(() => {
|
|
|
58206
58375
|
init_Settings();
|
|
58207
58376
|
init_transformOps();
|
|
58208
58377
|
init_BaseItem();
|
|
58378
|
+
init_Group();
|
|
58209
58379
|
init_Color();
|
|
58210
58380
|
init_ConnectorTypes();
|
|
58211
58381
|
init_connectorOps();
|
|
@@ -58295,8 +58465,9 @@ var init_Connector = __esm(() => {
|
|
|
58295
58465
|
const point5 = this.startPoint;
|
|
58296
58466
|
if (point5.pointType !== "Board") {
|
|
58297
58467
|
point5.recalculatePoint();
|
|
58298
|
-
const
|
|
58299
|
-
const
|
|
58468
|
+
const isGroupMoving = Group.movingGroupId !== null;
|
|
58469
|
+
const j1 = isGroupMoving ? false : this.smartJumpStartEdge();
|
|
58470
|
+
const j2 = isGroupMoving ? false : this.smartJumpEndEdge();
|
|
58300
58471
|
if (!j1 && !j2) {
|
|
58301
58472
|
this.updatePaths();
|
|
58302
58473
|
this.subject.publish(this);
|
|
@@ -58307,8 +58478,9 @@ var init_Connector = __esm(() => {
|
|
|
58307
58478
|
const point5 = this.endPoint;
|
|
58308
58479
|
if (point5.pointType !== "Board") {
|
|
58309
58480
|
point5.recalculatePoint();
|
|
58310
|
-
const
|
|
58311
|
-
const
|
|
58481
|
+
const isGroupMoving = Group.movingGroupId !== null;
|
|
58482
|
+
const j1 = isGroupMoving ? false : this.smartJumpEndEdge();
|
|
58483
|
+
const j2 = isGroupMoving ? false : this.smartJumpStartEdge();
|
|
58312
58484
|
if (!j1 && !j2) {
|
|
58313
58485
|
this.updatePaths();
|
|
58314
58486
|
this.subject.publish(this);
|
|
@@ -58322,14 +58494,19 @@ var init_Connector = __esm(() => {
|
|
|
58322
58494
|
if (start.pointType !== "Fixed" && start.pointType !== "Floating")
|
|
58323
58495
|
return false;
|
|
58324
58496
|
const item = start.item;
|
|
58325
|
-
const
|
|
58326
|
-
if (!
|
|
58497
|
+
const localAnchors = item.getSnapAnchorPoints?.();
|
|
58498
|
+
if (!localAnchors || localAnchors.length === 0)
|
|
58327
58499
|
return false;
|
|
58500
|
+
const anchors = item instanceof BaseItem && item.parent !== "Board" ? localAnchors.map((a2) => {
|
|
58501
|
+
const p3 = a2.copy();
|
|
58502
|
+
item.getParentWorldMatrix().apply(p3);
|
|
58503
|
+
return p3;
|
|
58504
|
+
}) : localAnchors;
|
|
58328
58505
|
const EPS = 2;
|
|
58329
58506
|
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
|
|
58330
58507
|
if (!isOnAnchor)
|
|
58331
58508
|
return false;
|
|
58332
|
-
const center = item.getMbr().getCenter();
|
|
58509
|
+
const center = item instanceof BaseItem && item.parent !== "Board" ? item.getWorldMbr().getCenter() : item.getMbr().getCenter();
|
|
58333
58510
|
const dx = this.endPoint.x - center.x;
|
|
58334
58511
|
const dy = this.endPoint.y - center.y;
|
|
58335
58512
|
if (dx === 0 && dy === 0)
|
|
@@ -58360,14 +58537,19 @@ var init_Connector = __esm(() => {
|
|
|
58360
58537
|
if (end.pointType !== "Fixed" && end.pointType !== "Floating")
|
|
58361
58538
|
return false;
|
|
58362
58539
|
const item = end.item;
|
|
58363
|
-
const
|
|
58364
|
-
if (!
|
|
58540
|
+
const localAnchors = item.getSnapAnchorPoints?.();
|
|
58541
|
+
if (!localAnchors || localAnchors.length === 0)
|
|
58365
58542
|
return false;
|
|
58543
|
+
const anchors = item instanceof BaseItem && item.parent !== "Board" ? localAnchors.map((a2) => {
|
|
58544
|
+
const p3 = a2.copy();
|
|
58545
|
+
item.getParentWorldMatrix().apply(p3);
|
|
58546
|
+
return p3;
|
|
58547
|
+
}) : localAnchors;
|
|
58366
58548
|
const EPS = 2;
|
|
58367
58549
|
const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
|
|
58368
58550
|
if (!isOnAnchor)
|
|
58369
58551
|
return false;
|
|
58370
|
-
const center = item.getMbr().getCenter();
|
|
58552
|
+
const center = item instanceof BaseItem && item.parent !== "Board" ? item.getWorldMbr().getCenter() : item.getMbr().getCenter();
|
|
58371
58553
|
const dx = this.startPoint.x - center.x;
|
|
58372
58554
|
const dy = this.startPoint.y - center.y;
|
|
58373
58555
|
if (dx === 0 && dy === 0)
|
|
@@ -63611,169 +63793,6 @@ var init_Placeholder2 = __esm(() => {
|
|
|
63611
63793
|
init_Placeholder();
|
|
63612
63794
|
});
|
|
63613
63795
|
|
|
63614
|
-
// src/Items/Group/Group.ts
|
|
63615
|
-
var Group;
|
|
63616
|
-
var init_Group = __esm(() => {
|
|
63617
|
-
init_Mbr();
|
|
63618
|
-
init_Point();
|
|
63619
|
-
init_BaseItem();
|
|
63620
|
-
Group = class Group extends BaseItem {
|
|
63621
|
-
events;
|
|
63622
|
-
itemType = "Group";
|
|
63623
|
-
parent = "Board";
|
|
63624
|
-
subject = new Subject;
|
|
63625
|
-
transformationRenderBlock = undefined;
|
|
63626
|
-
isLockedGroup = false;
|
|
63627
|
-
constructor(board, events, childIds = [], id = "") {
|
|
63628
|
-
super(board, id, undefined, true);
|
|
63629
|
-
this.events = events;
|
|
63630
|
-
this.canBeNested = true;
|
|
63631
|
-
if (childIds.length > 0) {
|
|
63632
|
-
this.applyAddChildren(childIds);
|
|
63633
|
-
}
|
|
63634
|
-
}
|
|
63635
|
-
isClosed() {
|
|
63636
|
-
return false;
|
|
63637
|
-
}
|
|
63638
|
-
getRichText() {
|
|
63639
|
-
return null;
|
|
63640
|
-
}
|
|
63641
|
-
apply(op) {
|
|
63642
|
-
switch (op.class) {
|
|
63643
|
-
case "Transformation":
|
|
63644
|
-
super.apply(op);
|
|
63645
|
-
this.updateMbr();
|
|
63646
|
-
break;
|
|
63647
|
-
case "Group":
|
|
63648
|
-
if (op.method === "addChild") {
|
|
63649
|
-
this.applyAddChildren([op.childId]);
|
|
63650
|
-
} else if (op.method === "removeChild") {
|
|
63651
|
-
this.applyRemoveChildren([op.childId]);
|
|
63652
|
-
} else {
|
|
63653
|
-
super.apply(op);
|
|
63654
|
-
}
|
|
63655
|
-
break;
|
|
63656
|
-
default:
|
|
63657
|
-
super.apply(op);
|
|
63658
|
-
return;
|
|
63659
|
-
}
|
|
63660
|
-
this.subject.publish(this);
|
|
63661
|
-
}
|
|
63662
|
-
emit(operation) {
|
|
63663
|
-
if (this.events) {
|
|
63664
|
-
const command = new GroupCommand([this], operation);
|
|
63665
|
-
command.apply();
|
|
63666
|
-
this.events.emit(operation, command);
|
|
63667
|
-
} else {
|
|
63668
|
-
this.apply(operation);
|
|
63669
|
-
}
|
|
63670
|
-
}
|
|
63671
|
-
setId(id) {
|
|
63672
|
-
this.id = id;
|
|
63673
|
-
this.transformation.setId(id);
|
|
63674
|
-
return this;
|
|
63675
|
-
}
|
|
63676
|
-
getMbr() {
|
|
63677
|
-
const children = this.index.listAll();
|
|
63678
|
-
if (children.length === 0) {
|
|
63679
|
-
return new Mbr(this.left, this.top, this.right, this.bottom);
|
|
63680
|
-
}
|
|
63681
|
-
const groupWorldMatrix = this.getWorldMatrix();
|
|
63682
|
-
let left = Number.MAX_SAFE_INTEGER;
|
|
63683
|
-
let top = Number.MAX_SAFE_INTEGER;
|
|
63684
|
-
let right = Number.MIN_SAFE_INTEGER;
|
|
63685
|
-
let bottom = Number.MIN_SAFE_INTEGER;
|
|
63686
|
-
for (const child of children) {
|
|
63687
|
-
const childLocalMbr = child.getMbr();
|
|
63688
|
-
const corners = [
|
|
63689
|
-
new Point(childLocalMbr.left, childLocalMbr.top),
|
|
63690
|
-
new Point(childLocalMbr.right, childLocalMbr.top),
|
|
63691
|
-
new Point(childLocalMbr.right, childLocalMbr.bottom),
|
|
63692
|
-
new Point(childLocalMbr.left, childLocalMbr.bottom)
|
|
63693
|
-
];
|
|
63694
|
-
for (const corner of corners) {
|
|
63695
|
-
groupWorldMatrix.apply(corner);
|
|
63696
|
-
if (corner.x < left)
|
|
63697
|
-
left = corner.x;
|
|
63698
|
-
if (corner.y < top)
|
|
63699
|
-
top = corner.y;
|
|
63700
|
-
if (corner.x > right)
|
|
63701
|
-
right = corner.x;
|
|
63702
|
-
if (corner.y > bottom)
|
|
63703
|
-
bottom = corner.y;
|
|
63704
|
-
}
|
|
63705
|
-
}
|
|
63706
|
-
const mbr = new Mbr(left, top, right, bottom);
|
|
63707
|
-
this.left = left;
|
|
63708
|
-
this.top = top;
|
|
63709
|
-
this.right = right;
|
|
63710
|
-
this.bottom = bottom;
|
|
63711
|
-
return mbr;
|
|
63712
|
-
}
|
|
63713
|
-
updateMbr() {
|
|
63714
|
-
this.getMbr();
|
|
63715
|
-
}
|
|
63716
|
-
getChildrenIds() {
|
|
63717
|
-
return this.index.listAll().map((item) => item.getId());
|
|
63718
|
-
}
|
|
63719
|
-
getChildren() {
|
|
63720
|
-
return this.index.listAll();
|
|
63721
|
-
}
|
|
63722
|
-
getLinkTo() {
|
|
63723
|
-
return this.linkTo.link;
|
|
63724
|
-
}
|
|
63725
|
-
serialize() {
|
|
63726
|
-
return {
|
|
63727
|
-
id: this.id,
|
|
63728
|
-
itemType: "Group",
|
|
63729
|
-
childIds: this.getChildrenIds(),
|
|
63730
|
-
transformation: this.transformation.serialize(),
|
|
63731
|
-
isLockedGroup: this.isLockedGroup
|
|
63732
|
-
};
|
|
63733
|
-
}
|
|
63734
|
-
deserialize(data) {
|
|
63735
|
-
if (data.transformation) {
|
|
63736
|
-
this.transformation.deserialize(data.transformation);
|
|
63737
|
-
}
|
|
63738
|
-
if (data.childIds && data.childIds.length > 0) {
|
|
63739
|
-
this.applyAddChildren(data.childIds);
|
|
63740
|
-
}
|
|
63741
|
-
if (data.isLockedGroup !== undefined) {
|
|
63742
|
-
this.isLockedGroup = data.isLockedGroup;
|
|
63743
|
-
}
|
|
63744
|
-
this.updateMbr();
|
|
63745
|
-
this.subject.publish(this);
|
|
63746
|
-
return this;
|
|
63747
|
-
}
|
|
63748
|
-
getId() {
|
|
63749
|
-
return this.id;
|
|
63750
|
-
}
|
|
63751
|
-
getIntersectionPoints(segment) {
|
|
63752
|
-
const lines = this.getMbr().getLines();
|
|
63753
|
-
const initPoints = [];
|
|
63754
|
-
return lines.reduce((acc, line) => {
|
|
63755
|
-
const intersections = line.getIntersectionPoints(segment);
|
|
63756
|
-
if (intersections.length > 0) {
|
|
63757
|
-
acc.push(...intersections);
|
|
63758
|
-
}
|
|
63759
|
-
return acc;
|
|
63760
|
-
}, initPoints);
|
|
63761
|
-
}
|
|
63762
|
-
render(context) {
|
|
63763
|
-
if (this.transformationRenderBlock) {
|
|
63764
|
-
return;
|
|
63765
|
-
}
|
|
63766
|
-
const ctx = context.ctx;
|
|
63767
|
-
ctx.save();
|
|
63768
|
-
this.transformation.applyToContext(ctx);
|
|
63769
|
-
for (const child of this.index.listAll()) {
|
|
63770
|
-
child.render(context);
|
|
63771
|
-
}
|
|
63772
|
-
ctx.restore();
|
|
63773
|
-
}
|
|
63774
|
-
};
|
|
63775
|
-
});
|
|
63776
|
-
|
|
63777
63796
|
// src/Items/Group/index.ts
|
|
63778
63797
|
var init_Group2 = __esm(() => {
|
|
63779
63798
|
init_Group();
|