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/node.js CHANGED
@@ -60588,6 +60588,175 @@ var init_getLine = __esm(() => {
60588
60588
  init_getStraightLine();
60589
60589
  });
60590
60590
 
60591
+ // src/Items/Group/Group.ts
60592
+ var Group;
60593
+ var init_Group = __esm(() => {
60594
+ init_Mbr();
60595
+ init_Point();
60596
+ init_BaseItem();
60597
+ Group = class Group extends BaseItem {
60598
+ events;
60599
+ itemType = "Group";
60600
+ parent = "Board";
60601
+ subject = new Subject;
60602
+ transformationRenderBlock = undefined;
60603
+ isLockedGroup = false;
60604
+ static movingGroupId = null;
60605
+ constructor(board, events, childIds = [], id = "") {
60606
+ super(board, id, undefined, true);
60607
+ this.events = events;
60608
+ this.canBeNested = true;
60609
+ if (childIds.length > 0) {
60610
+ this.applyAddChildren(childIds);
60611
+ }
60612
+ }
60613
+ isClosed() {
60614
+ return false;
60615
+ }
60616
+ getRichText() {
60617
+ return null;
60618
+ }
60619
+ apply(op) {
60620
+ switch (op.class) {
60621
+ case "Transformation":
60622
+ super.apply(op);
60623
+ this.updateMbr();
60624
+ Group.movingGroupId = this.id;
60625
+ for (const child of this.index.listAll()) {
60626
+ child.subject.publish(child);
60627
+ }
60628
+ Group.movingGroupId = null;
60629
+ break;
60630
+ case "Group":
60631
+ if (op.method === "addChild") {
60632
+ this.applyAddChildren([op.childId]);
60633
+ } else if (op.method === "removeChild") {
60634
+ this.applyRemoveChildren([op.childId]);
60635
+ } else {
60636
+ super.apply(op);
60637
+ }
60638
+ break;
60639
+ default:
60640
+ super.apply(op);
60641
+ return;
60642
+ }
60643
+ this.subject.publish(this);
60644
+ }
60645
+ emit(operation) {
60646
+ if (this.events) {
60647
+ const command = new GroupCommand([this], operation);
60648
+ command.apply();
60649
+ this.events.emit(operation, command);
60650
+ } else {
60651
+ this.apply(operation);
60652
+ }
60653
+ }
60654
+ setId(id) {
60655
+ this.id = id;
60656
+ this.transformation.setId(id);
60657
+ return this;
60658
+ }
60659
+ getMbr() {
60660
+ const children = this.index.listAll();
60661
+ if (children.length === 0) {
60662
+ return new Mbr(this.left, this.top, this.right, this.bottom);
60663
+ }
60664
+ const groupWorldMatrix = this.getWorldMatrix();
60665
+ let left = Number.MAX_SAFE_INTEGER;
60666
+ let top = Number.MAX_SAFE_INTEGER;
60667
+ let right = Number.MIN_SAFE_INTEGER;
60668
+ let bottom = Number.MIN_SAFE_INTEGER;
60669
+ for (const child of children) {
60670
+ const childLocalMbr = child.getMbr();
60671
+ const corners = [
60672
+ new Point(childLocalMbr.left, childLocalMbr.top),
60673
+ new Point(childLocalMbr.right, childLocalMbr.top),
60674
+ new Point(childLocalMbr.right, childLocalMbr.bottom),
60675
+ new Point(childLocalMbr.left, childLocalMbr.bottom)
60676
+ ];
60677
+ for (const corner of corners) {
60678
+ groupWorldMatrix.apply(corner);
60679
+ if (corner.x < left)
60680
+ left = corner.x;
60681
+ if (corner.y < top)
60682
+ top = corner.y;
60683
+ if (corner.x > right)
60684
+ right = corner.x;
60685
+ if (corner.y > bottom)
60686
+ bottom = corner.y;
60687
+ }
60688
+ }
60689
+ const mbr = new Mbr(left, top, right, bottom);
60690
+ this.left = left;
60691
+ this.top = top;
60692
+ this.right = right;
60693
+ this.bottom = bottom;
60694
+ return mbr;
60695
+ }
60696
+ updateMbr() {
60697
+ this.getMbr();
60698
+ }
60699
+ getChildrenIds() {
60700
+ return this.index.listAll().map((item) => item.getId());
60701
+ }
60702
+ getChildren() {
60703
+ return this.index.listAll();
60704
+ }
60705
+ getLinkTo() {
60706
+ return this.linkTo.link;
60707
+ }
60708
+ serialize() {
60709
+ return {
60710
+ id: this.id,
60711
+ itemType: "Group",
60712
+ childIds: this.getChildrenIds(),
60713
+ transformation: this.transformation.serialize(),
60714
+ isLockedGroup: this.isLockedGroup
60715
+ };
60716
+ }
60717
+ deserialize(data) {
60718
+ if (data.transformation) {
60719
+ this.transformation.deserialize(data.transformation);
60720
+ }
60721
+ if (data.childIds && data.childIds.length > 0) {
60722
+ this.applyAddChildren(data.childIds);
60723
+ }
60724
+ if (data.isLockedGroup !== undefined) {
60725
+ this.isLockedGroup = data.isLockedGroup;
60726
+ }
60727
+ this.updateMbr();
60728
+ this.subject.publish(this);
60729
+ return this;
60730
+ }
60731
+ getId() {
60732
+ return this.id;
60733
+ }
60734
+ getIntersectionPoints(segment) {
60735
+ const lines = this.getMbr().getLines();
60736
+ const initPoints = [];
60737
+ return lines.reduce((acc, line) => {
60738
+ const intersections = line.getIntersectionPoints(segment);
60739
+ if (intersections.length > 0) {
60740
+ acc.push(...intersections);
60741
+ }
60742
+ return acc;
60743
+ }, initPoints);
60744
+ }
60745
+ render(context) {
60746
+ if (this.transformationRenderBlock) {
60747
+ return;
60748
+ }
60749
+ const ctx = context.ctx;
60750
+ ctx.save();
60751
+ this.transformation.applyToContext(ctx);
60752
+ for (const child of this.index.listAll()) {
60753
+ child.render(context);
60754
+ }
60755
+ ctx.restore();
60756
+ }
60757
+ };
60758
+ });
60759
+
60591
60760
  // src/Items/Connector/ConnectorTypes.ts
60592
60761
  var ConnectionLineWidths, CONNECTOR_COLOR = "rgb(20, 21, 26)", CONNECTOR_LINE_WIDTH = 1, CONNECTOR_BORDER_STYLE = "solid", DEFAULT_END_POINTER = "TriangleFilled", CONNECTOR_POINTER_TYPES;
60593
60762
  var init_ConnectorTypes = __esm(() => {
@@ -60696,6 +60865,7 @@ var init_Connector = __esm(() => {
60696
60865
  init_Settings();
60697
60866
  init_transformOps();
60698
60867
  init_BaseItem();
60868
+ init_Group();
60699
60869
  init_Color();
60700
60870
  init_ConnectorTypes();
60701
60871
  init_connectorOps();
@@ -60785,8 +60955,9 @@ var init_Connector = __esm(() => {
60785
60955
  const point5 = this.startPoint;
60786
60956
  if (point5.pointType !== "Board") {
60787
60957
  point5.recalculatePoint();
60788
- const j1 = this.smartJumpStartEdge();
60789
- const j2 = this.smartJumpEndEdge();
60958
+ const isGroupMoving = Group.movingGroupId !== null;
60959
+ const j1 = isGroupMoving ? false : this.smartJumpStartEdge();
60960
+ const j2 = isGroupMoving ? false : this.smartJumpEndEdge();
60790
60961
  if (!j1 && !j2) {
60791
60962
  this.updatePaths();
60792
60963
  this.subject.publish(this);
@@ -60797,8 +60968,9 @@ var init_Connector = __esm(() => {
60797
60968
  const point5 = this.endPoint;
60798
60969
  if (point5.pointType !== "Board") {
60799
60970
  point5.recalculatePoint();
60800
- const j1 = this.smartJumpEndEdge();
60801
- const j2 = this.smartJumpStartEdge();
60971
+ const isGroupMoving = Group.movingGroupId !== null;
60972
+ const j1 = isGroupMoving ? false : this.smartJumpEndEdge();
60973
+ const j2 = isGroupMoving ? false : this.smartJumpStartEdge();
60802
60974
  if (!j1 && !j2) {
60803
60975
  this.updatePaths();
60804
60976
  this.subject.publish(this);
@@ -60812,14 +60984,19 @@ var init_Connector = __esm(() => {
60812
60984
  if (start.pointType !== "Fixed" && start.pointType !== "Floating")
60813
60985
  return false;
60814
60986
  const item = start.item;
60815
- const anchors = item.getSnapAnchorPoints?.();
60816
- if (!anchors || anchors.length === 0)
60987
+ const localAnchors = item.getSnapAnchorPoints?.();
60988
+ if (!localAnchors || localAnchors.length === 0)
60817
60989
  return false;
60990
+ const anchors = item instanceof BaseItem && item.parent !== "Board" ? localAnchors.map((a2) => {
60991
+ const p3 = a2.copy();
60992
+ item.getParentWorldMatrix().apply(p3);
60993
+ return p3;
60994
+ }) : localAnchors;
60818
60995
  const EPS = 2;
60819
60996
  const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
60820
60997
  if (!isOnAnchor)
60821
60998
  return false;
60822
- const center = item.getMbr().getCenter();
60999
+ const center = item instanceof BaseItem && item.parent !== "Board" ? item.getWorldMbr().getCenter() : item.getMbr().getCenter();
60823
61000
  const dx = this.endPoint.x - center.x;
60824
61001
  const dy = this.endPoint.y - center.y;
60825
61002
  if (dx === 0 && dy === 0)
@@ -60850,14 +61027,19 @@ var init_Connector = __esm(() => {
60850
61027
  if (end.pointType !== "Fixed" && end.pointType !== "Floating")
60851
61028
  return false;
60852
61029
  const item = end.item;
60853
- const anchors = item.getSnapAnchorPoints?.();
60854
- if (!anchors || anchors.length === 0)
61030
+ const localAnchors = item.getSnapAnchorPoints?.();
61031
+ if (!localAnchors || localAnchors.length === 0)
60855
61032
  return false;
61033
+ const anchors = item instanceof BaseItem && item.parent !== "Board" ? localAnchors.map((a2) => {
61034
+ const p3 = a2.copy();
61035
+ item.getParentWorldMatrix().apply(p3);
61036
+ return p3;
61037
+ }) : localAnchors;
60856
61038
  const EPS = 2;
60857
61039
  const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - end.x) < EPS && Math.abs(a2.y - end.y) < EPS);
60858
61040
  if (!isOnAnchor)
60859
61041
  return false;
60860
- const center = item.getMbr().getCenter();
61042
+ const center = item instanceof BaseItem && item.parent !== "Board" ? item.getWorldMbr().getCenter() : item.getMbr().getCenter();
60861
61043
  const dx = this.startPoint.x - center.x;
60862
61044
  const dy = this.startPoint.y - center.y;
60863
61045
  if (dx === 0 && dy === 0)
@@ -66101,169 +66283,6 @@ var init_Placeholder2 = __esm(() => {
66101
66283
  init_Placeholder();
66102
66284
  });
66103
66285
 
66104
- // src/Items/Group/Group.ts
66105
- var Group;
66106
- var init_Group = __esm(() => {
66107
- init_Mbr();
66108
- init_Point();
66109
- init_BaseItem();
66110
- Group = class Group extends BaseItem {
66111
- events;
66112
- itemType = "Group";
66113
- parent = "Board";
66114
- subject = new Subject;
66115
- transformationRenderBlock = undefined;
66116
- isLockedGroup = false;
66117
- constructor(board, events, childIds = [], id = "") {
66118
- super(board, id, undefined, true);
66119
- this.events = events;
66120
- this.canBeNested = true;
66121
- if (childIds.length > 0) {
66122
- this.applyAddChildren(childIds);
66123
- }
66124
- }
66125
- isClosed() {
66126
- return false;
66127
- }
66128
- getRichText() {
66129
- return null;
66130
- }
66131
- apply(op) {
66132
- switch (op.class) {
66133
- case "Transformation":
66134
- super.apply(op);
66135
- this.updateMbr();
66136
- break;
66137
- case "Group":
66138
- if (op.method === "addChild") {
66139
- this.applyAddChildren([op.childId]);
66140
- } else if (op.method === "removeChild") {
66141
- this.applyRemoveChildren([op.childId]);
66142
- } else {
66143
- super.apply(op);
66144
- }
66145
- break;
66146
- default:
66147
- super.apply(op);
66148
- return;
66149
- }
66150
- this.subject.publish(this);
66151
- }
66152
- emit(operation) {
66153
- if (this.events) {
66154
- const command = new GroupCommand([this], operation);
66155
- command.apply();
66156
- this.events.emit(operation, command);
66157
- } else {
66158
- this.apply(operation);
66159
- }
66160
- }
66161
- setId(id) {
66162
- this.id = id;
66163
- this.transformation.setId(id);
66164
- return this;
66165
- }
66166
- getMbr() {
66167
- const children = this.index.listAll();
66168
- if (children.length === 0) {
66169
- return new Mbr(this.left, this.top, this.right, this.bottom);
66170
- }
66171
- const groupWorldMatrix = this.getWorldMatrix();
66172
- let left = Number.MAX_SAFE_INTEGER;
66173
- let top = Number.MAX_SAFE_INTEGER;
66174
- let right = Number.MIN_SAFE_INTEGER;
66175
- let bottom = Number.MIN_SAFE_INTEGER;
66176
- for (const child of children) {
66177
- const childLocalMbr = child.getMbr();
66178
- const corners = [
66179
- new Point(childLocalMbr.left, childLocalMbr.top),
66180
- new Point(childLocalMbr.right, childLocalMbr.top),
66181
- new Point(childLocalMbr.right, childLocalMbr.bottom),
66182
- new Point(childLocalMbr.left, childLocalMbr.bottom)
66183
- ];
66184
- for (const corner of corners) {
66185
- groupWorldMatrix.apply(corner);
66186
- if (corner.x < left)
66187
- left = corner.x;
66188
- if (corner.y < top)
66189
- top = corner.y;
66190
- if (corner.x > right)
66191
- right = corner.x;
66192
- if (corner.y > bottom)
66193
- bottom = corner.y;
66194
- }
66195
- }
66196
- const mbr = new Mbr(left, top, right, bottom);
66197
- this.left = left;
66198
- this.top = top;
66199
- this.right = right;
66200
- this.bottom = bottom;
66201
- return mbr;
66202
- }
66203
- updateMbr() {
66204
- this.getMbr();
66205
- }
66206
- getChildrenIds() {
66207
- return this.index.listAll().map((item) => item.getId());
66208
- }
66209
- getChildren() {
66210
- return this.index.listAll();
66211
- }
66212
- getLinkTo() {
66213
- return this.linkTo.link;
66214
- }
66215
- serialize() {
66216
- return {
66217
- id: this.id,
66218
- itemType: "Group",
66219
- childIds: this.getChildrenIds(),
66220
- transformation: this.transformation.serialize(),
66221
- isLockedGroup: this.isLockedGroup
66222
- };
66223
- }
66224
- deserialize(data) {
66225
- if (data.transformation) {
66226
- this.transformation.deserialize(data.transformation);
66227
- }
66228
- if (data.childIds && data.childIds.length > 0) {
66229
- this.applyAddChildren(data.childIds);
66230
- }
66231
- if (data.isLockedGroup !== undefined) {
66232
- this.isLockedGroup = data.isLockedGroup;
66233
- }
66234
- this.updateMbr();
66235
- this.subject.publish(this);
66236
- return this;
66237
- }
66238
- getId() {
66239
- return this.id;
66240
- }
66241
- getIntersectionPoints(segment) {
66242
- const lines = this.getMbr().getLines();
66243
- const initPoints = [];
66244
- return lines.reduce((acc, line) => {
66245
- const intersections = line.getIntersectionPoints(segment);
66246
- if (intersections.length > 0) {
66247
- acc.push(...intersections);
66248
- }
66249
- return acc;
66250
- }, initPoints);
66251
- }
66252
- render(context) {
66253
- if (this.transformationRenderBlock) {
66254
- return;
66255
- }
66256
- const ctx = context.ctx;
66257
- ctx.save();
66258
- this.transformation.applyToContext(ctx);
66259
- for (const child of this.index.listAll()) {
66260
- child.render(context);
66261
- }
66262
- ctx.restore();
66263
- }
66264
- };
66265
- });
66266
-
66267
66286
  // src/Items/Group/index.ts
66268
66287
  var init_Group2 = __esm(() => {
66269
66288
  init_Group();