microboard-temp 0.13.66 → 0.13.68

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.
@@ -61039,7 +61039,7 @@ class ForceGraphEngine {
61039
61039
  const dist = Math.sqrt(dx * dx + dy * dy) || 1;
61040
61040
  const maxDimA = Math.max(s1.w, s1.h);
61041
61041
  const maxDimB = Math.max(s2.w, s2.h);
61042
- const targetDist = (maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB);
61042
+ const targetDist = ((maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB)) * 1.5;
61043
61043
  const force = (dist - targetDist) * conf.FG_SPRING_K;
61044
61044
  const fx = dx / dist * force;
61045
61045
  const fy = dy / dist * force;
@@ -61929,11 +61929,14 @@ class Board {
61929
61929
  }
61930
61930
  const newMap = {};
61931
61931
  const childItemIds = new Set;
61932
+ const childToParent = new Map;
61932
61933
  for (const itemId in itemsMap) {
61933
61934
  const d = itemsMap[itemId];
61934
61935
  if (Array.isArray(d.childIds)) {
61935
- for (const cid of d.childIds)
61936
+ for (const cid of d.childIds) {
61936
61937
  childItemIds.add(cid);
61938
+ childToParent.set(cid, itemId);
61939
+ }
61937
61940
  }
61938
61941
  }
61939
61942
  console.log("[paste] childItemIds:", [...childItemIds]);
@@ -62015,7 +62018,28 @@ class Board {
62015
62018
  }
62016
62019
  }
62017
62020
  } else if (childItemIds.has(itemId)) {
62018
- console.log(`[paste] SKIP child ${itemData.itemType} ${itemId}: keeping local (${translateX},${translateY})`);
62021
+ const parentId = childToParent.get(itemId);
62022
+ const parentData = parentId ? itemsMap[parentId] : undefined;
62023
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
62024
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
62025
+ const parentNewTx = parentOrigTx - minX + x;
62026
+ const parentNewTy = parentOrigTy - minY + y;
62027
+ const newChildTx = parentNewTx + translateX;
62028
+ const newChildTy = parentNewTy + translateY;
62029
+ console.log(`[paste] child ${itemData.itemType} ${itemId}: local=(${translateX},${translateY}) parentNew=(${parentNewTx},${parentNewTy}) → world=(${newChildTx},${newChildTy})`);
62030
+ if (itemData.transformation) {
62031
+ itemData.transformation.translateX = newChildTx;
62032
+ itemData.transformation.translateY = newChildTy;
62033
+ const d2 = itemData;
62034
+ if (d2.text && typeof d2.text === "object") {
62035
+ const textData = d2.text;
62036
+ if (textData.transformation && typeof textData.transformation === "object") {
62037
+ const tt = textData.transformation;
62038
+ tt.translateX = newChildTx;
62039
+ tt.translateY = newChildTy;
62040
+ }
62041
+ }
62042
+ }
62019
62043
  }
62020
62044
  if (itemData.itemType !== "RichText" && "childIds" in itemData && itemData.childIds?.length) {
62021
62045
  const itemDataWithChildren = itemData;
@@ -62097,9 +62121,22 @@ class Board {
62097
62121
  }
62098
62122
  }
62099
62123
  const newMap = {};
62124
+ const dupChildItemIds = new Set;
62125
+ const dupChildToParent = new Map;
62126
+ for (const itemId in itemsMap) {
62127
+ const d = itemsMap[itemId];
62128
+ if (Array.isArray(d.childIds)) {
62129
+ for (const cid of d.childIds) {
62130
+ dupChildItemIds.add(cid);
62131
+ dupChildToParent.set(cid, itemId);
62132
+ }
62133
+ }
62134
+ }
62100
62135
  let minX = Infinity;
62101
62136
  let minY = Infinity;
62102
62137
  for (const itemId in itemsMap) {
62138
+ if (dupChildItemIds.has(itemId))
62139
+ continue;
62103
62140
  const itemData = itemsMap[itemId];
62104
62141
  const { translateX, translateY } = itemData.transformation || {
62105
62142
  translateX: 0,
@@ -62145,6 +62182,28 @@ class Board {
62145
62182
  itemData.middlePoint.x += -minX + right + width2;
62146
62183
  itemData.middlePoint.y += -minY + top;
62147
62184
  }
62185
+ } else if (dupChildItemIds.has(itemId)) {
62186
+ const parentId = dupChildToParent.get(itemId);
62187
+ const parentData = parentId ? itemsMap[parentId] : undefined;
62188
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
62189
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
62190
+ const parentNewTx = parentOrigTx - minX + right + width2;
62191
+ const parentNewTy = parentOrigTy - minY + top;
62192
+ if (itemData.transformation) {
62193
+ const newChildTx = parentNewTx + translateX;
62194
+ const newChildTy = parentNewTy + translateY;
62195
+ itemData.transformation.translateX = newChildTx;
62196
+ itemData.transformation.translateY = newChildTy;
62197
+ itemData.transformation.isLocked = false;
62198
+ const d2 = itemData;
62199
+ if (d2.text && typeof d2.text === "object") {
62200
+ const tt = d2.text.transformation;
62201
+ if (tt) {
62202
+ tt.translateX = newChildTx;
62203
+ tt.translateY = newChildTy;
62204
+ }
62205
+ }
62206
+ }
62148
62207
  } else if (itemData.transformation) {
62149
62208
  itemData.transformation.translateX = translateX - minX + right + width2;
62150
62209
  itemData.transformation.translateY = translateY - minY + top;
@@ -62155,6 +62214,14 @@ class Board {
62155
62214
  if (height3 === 0 || isSelectedItemsMinWidth) {
62156
62215
  itemData.transformation.translateX = translateX + width2 * 10 + 10;
62157
62216
  }
62217
+ const d2 = itemData;
62218
+ if (d2.text && typeof d2.text === "object") {
62219
+ const tt = d2.text.transformation;
62220
+ if (tt) {
62221
+ tt.translateX = itemData.transformation.translateX;
62222
+ tt.translateY = itemData.transformation.translateY;
62223
+ }
62224
+ }
62158
62225
  }
62159
62226
  const itemDataWithChildren = itemData;
62160
62227
  if ("childIds" in itemDataWithChildren && itemDataWithChildren.childIds?.length) {
package/dist/cjs/index.js CHANGED
@@ -61039,7 +61039,7 @@ class ForceGraphEngine {
61039
61039
  const dist = Math.sqrt(dx * dx + dy * dy) || 1;
61040
61040
  const maxDimA = Math.max(s1.w, s1.h);
61041
61041
  const maxDimB = Math.max(s2.w, s2.h);
61042
- const targetDist = (maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB);
61042
+ const targetDist = ((maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB)) * 1.5;
61043
61043
  const force = (dist - targetDist) * conf.FG_SPRING_K;
61044
61044
  const fx = dx / dist * force;
61045
61045
  const fy = dy / dist * force;
@@ -61929,11 +61929,14 @@ class Board {
61929
61929
  }
61930
61930
  const newMap = {};
61931
61931
  const childItemIds = new Set;
61932
+ const childToParent = new Map;
61932
61933
  for (const itemId in itemsMap) {
61933
61934
  const d = itemsMap[itemId];
61934
61935
  if (Array.isArray(d.childIds)) {
61935
- for (const cid of d.childIds)
61936
+ for (const cid of d.childIds) {
61936
61937
  childItemIds.add(cid);
61938
+ childToParent.set(cid, itemId);
61939
+ }
61937
61940
  }
61938
61941
  }
61939
61942
  console.log("[paste] childItemIds:", [...childItemIds]);
@@ -62015,7 +62018,28 @@ class Board {
62015
62018
  }
62016
62019
  }
62017
62020
  } else if (childItemIds.has(itemId)) {
62018
- console.log(`[paste] SKIP child ${itemData.itemType} ${itemId}: keeping local (${translateX},${translateY})`);
62021
+ const parentId = childToParent.get(itemId);
62022
+ const parentData = parentId ? itemsMap[parentId] : undefined;
62023
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
62024
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
62025
+ const parentNewTx = parentOrigTx - minX + x;
62026
+ const parentNewTy = parentOrigTy - minY + y;
62027
+ const newChildTx = parentNewTx + translateX;
62028
+ const newChildTy = parentNewTy + translateY;
62029
+ console.log(`[paste] child ${itemData.itemType} ${itemId}: local=(${translateX},${translateY}) parentNew=(${parentNewTx},${parentNewTy}) → world=(${newChildTx},${newChildTy})`);
62030
+ if (itemData.transformation) {
62031
+ itemData.transformation.translateX = newChildTx;
62032
+ itemData.transformation.translateY = newChildTy;
62033
+ const d2 = itemData;
62034
+ if (d2.text && typeof d2.text === "object") {
62035
+ const textData = d2.text;
62036
+ if (textData.transformation && typeof textData.transformation === "object") {
62037
+ const tt = textData.transformation;
62038
+ tt.translateX = newChildTx;
62039
+ tt.translateY = newChildTy;
62040
+ }
62041
+ }
62042
+ }
62019
62043
  }
62020
62044
  if (itemData.itemType !== "RichText" && "childIds" in itemData && itemData.childIds?.length) {
62021
62045
  const itemDataWithChildren = itemData;
@@ -62097,9 +62121,22 @@ class Board {
62097
62121
  }
62098
62122
  }
62099
62123
  const newMap = {};
62124
+ const dupChildItemIds = new Set;
62125
+ const dupChildToParent = new Map;
62126
+ for (const itemId in itemsMap) {
62127
+ const d = itemsMap[itemId];
62128
+ if (Array.isArray(d.childIds)) {
62129
+ for (const cid of d.childIds) {
62130
+ dupChildItemIds.add(cid);
62131
+ dupChildToParent.set(cid, itemId);
62132
+ }
62133
+ }
62134
+ }
62100
62135
  let minX = Infinity;
62101
62136
  let minY = Infinity;
62102
62137
  for (const itemId in itemsMap) {
62138
+ if (dupChildItemIds.has(itemId))
62139
+ continue;
62103
62140
  const itemData = itemsMap[itemId];
62104
62141
  const { translateX, translateY } = itemData.transformation || {
62105
62142
  translateX: 0,
@@ -62145,6 +62182,28 @@ class Board {
62145
62182
  itemData.middlePoint.x += -minX + right + width2;
62146
62183
  itemData.middlePoint.y += -minY + top;
62147
62184
  }
62185
+ } else if (dupChildItemIds.has(itemId)) {
62186
+ const parentId = dupChildToParent.get(itemId);
62187
+ const parentData = parentId ? itemsMap[parentId] : undefined;
62188
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
62189
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
62190
+ const parentNewTx = parentOrigTx - minX + right + width2;
62191
+ const parentNewTy = parentOrigTy - minY + top;
62192
+ if (itemData.transformation) {
62193
+ const newChildTx = parentNewTx + translateX;
62194
+ const newChildTy = parentNewTy + translateY;
62195
+ itemData.transformation.translateX = newChildTx;
62196
+ itemData.transformation.translateY = newChildTy;
62197
+ itemData.transformation.isLocked = false;
62198
+ const d2 = itemData;
62199
+ if (d2.text && typeof d2.text === "object") {
62200
+ const tt = d2.text.transformation;
62201
+ if (tt) {
62202
+ tt.translateX = newChildTx;
62203
+ tt.translateY = newChildTy;
62204
+ }
62205
+ }
62206
+ }
62148
62207
  } else if (itemData.transformation) {
62149
62208
  itemData.transformation.translateX = translateX - minX + right + width2;
62150
62209
  itemData.transformation.translateY = translateY - minY + top;
@@ -62155,6 +62214,14 @@ class Board {
62155
62214
  if (height3 === 0 || isSelectedItemsMinWidth) {
62156
62215
  itemData.transformation.translateX = translateX + width2 * 10 + 10;
62157
62216
  }
62217
+ const d2 = itemData;
62218
+ if (d2.text && typeof d2.text === "object") {
62219
+ const tt = d2.text.transformation;
62220
+ if (tt) {
62221
+ tt.translateX = itemData.transformation.translateX;
62222
+ tt.translateY = itemData.transformation.translateY;
62223
+ }
62224
+ }
62158
62225
  }
62159
62226
  const itemDataWithChildren = itemData;
62160
62227
  if ("childIds" in itemDataWithChildren && itemDataWithChildren.childIds?.length) {
package/dist/cjs/node.js CHANGED
@@ -63514,7 +63514,7 @@ class ForceGraphEngine {
63514
63514
  const dist = Math.sqrt(dx * dx + dy * dy) || 1;
63515
63515
  const maxDimA = Math.max(s1.w, s1.h);
63516
63516
  const maxDimB = Math.max(s2.w, s2.h);
63517
- const targetDist = (maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB);
63517
+ const targetDist = ((maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB)) * 1.5;
63518
63518
  const force = (dist - targetDist) * conf.FG_SPRING_K;
63519
63519
  const fx = dx / dist * force;
63520
63520
  const fy = dy / dist * force;
@@ -64404,11 +64404,14 @@ class Board {
64404
64404
  }
64405
64405
  const newMap = {};
64406
64406
  const childItemIds = new Set;
64407
+ const childToParent = new Map;
64407
64408
  for (const itemId in itemsMap) {
64408
64409
  const d = itemsMap[itemId];
64409
64410
  if (Array.isArray(d.childIds)) {
64410
- for (const cid of d.childIds)
64411
+ for (const cid of d.childIds) {
64411
64412
  childItemIds.add(cid);
64413
+ childToParent.set(cid, itemId);
64414
+ }
64412
64415
  }
64413
64416
  }
64414
64417
  console.log("[paste] childItemIds:", [...childItemIds]);
@@ -64490,7 +64493,28 @@ class Board {
64490
64493
  }
64491
64494
  }
64492
64495
  } else if (childItemIds.has(itemId)) {
64493
- console.log(`[paste] SKIP child ${itemData.itemType} ${itemId}: keeping local (${translateX},${translateY})`);
64496
+ const parentId = childToParent.get(itemId);
64497
+ const parentData = parentId ? itemsMap[parentId] : undefined;
64498
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
64499
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
64500
+ const parentNewTx = parentOrigTx - minX + x;
64501
+ const parentNewTy = parentOrigTy - minY + y;
64502
+ const newChildTx = parentNewTx + translateX;
64503
+ const newChildTy = parentNewTy + translateY;
64504
+ console.log(`[paste] child ${itemData.itemType} ${itemId}: local=(${translateX},${translateY}) parentNew=(${parentNewTx},${parentNewTy}) → world=(${newChildTx},${newChildTy})`);
64505
+ if (itemData.transformation) {
64506
+ itemData.transformation.translateX = newChildTx;
64507
+ itemData.transformation.translateY = newChildTy;
64508
+ const d2 = itemData;
64509
+ if (d2.text && typeof d2.text === "object") {
64510
+ const textData = d2.text;
64511
+ if (textData.transformation && typeof textData.transformation === "object") {
64512
+ const tt = textData.transformation;
64513
+ tt.translateX = newChildTx;
64514
+ tt.translateY = newChildTy;
64515
+ }
64516
+ }
64517
+ }
64494
64518
  }
64495
64519
  if (itemData.itemType !== "RichText" && "childIds" in itemData && itemData.childIds?.length) {
64496
64520
  const itemDataWithChildren = itemData;
@@ -64572,9 +64596,22 @@ class Board {
64572
64596
  }
64573
64597
  }
64574
64598
  const newMap = {};
64599
+ const dupChildItemIds = new Set;
64600
+ const dupChildToParent = new Map;
64601
+ for (const itemId in itemsMap) {
64602
+ const d = itemsMap[itemId];
64603
+ if (Array.isArray(d.childIds)) {
64604
+ for (const cid of d.childIds) {
64605
+ dupChildItemIds.add(cid);
64606
+ dupChildToParent.set(cid, itemId);
64607
+ }
64608
+ }
64609
+ }
64575
64610
  let minX = Infinity;
64576
64611
  let minY = Infinity;
64577
64612
  for (const itemId in itemsMap) {
64613
+ if (dupChildItemIds.has(itemId))
64614
+ continue;
64578
64615
  const itemData = itemsMap[itemId];
64579
64616
  const { translateX, translateY } = itemData.transformation || {
64580
64617
  translateX: 0,
@@ -64620,6 +64657,28 @@ class Board {
64620
64657
  itemData.middlePoint.x += -minX + right + width2;
64621
64658
  itemData.middlePoint.y += -minY + top;
64622
64659
  }
64660
+ } else if (dupChildItemIds.has(itemId)) {
64661
+ const parentId = dupChildToParent.get(itemId);
64662
+ const parentData = parentId ? itemsMap[parentId] : undefined;
64663
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
64664
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
64665
+ const parentNewTx = parentOrigTx - minX + right + width2;
64666
+ const parentNewTy = parentOrigTy - minY + top;
64667
+ if (itemData.transformation) {
64668
+ const newChildTx = parentNewTx + translateX;
64669
+ const newChildTy = parentNewTy + translateY;
64670
+ itemData.transformation.translateX = newChildTx;
64671
+ itemData.transformation.translateY = newChildTy;
64672
+ itemData.transformation.isLocked = false;
64673
+ const d2 = itemData;
64674
+ if (d2.text && typeof d2.text === "object") {
64675
+ const tt = d2.text.transformation;
64676
+ if (tt) {
64677
+ tt.translateX = newChildTx;
64678
+ tt.translateY = newChildTy;
64679
+ }
64680
+ }
64681
+ }
64623
64682
  } else if (itemData.transformation) {
64624
64683
  itemData.transformation.translateX = translateX - minX + right + width2;
64625
64684
  itemData.transformation.translateY = translateY - minY + top;
@@ -64630,6 +64689,14 @@ class Board {
64630
64689
  if (height3 === 0 || isSelectedItemsMinWidth) {
64631
64690
  itemData.transformation.translateX = translateX + width2 * 10 + 10;
64632
64691
  }
64692
+ const d2 = itemData;
64693
+ if (d2.text && typeof d2.text === "object") {
64694
+ const tt = d2.text.transformation;
64695
+ if (tt) {
64696
+ tt.translateX = itemData.transformation.translateX;
64697
+ tt.translateY = itemData.transformation.translateY;
64698
+ }
64699
+ }
64633
64700
  }
64634
64701
  const itemDataWithChildren = itemData;
64635
64702
  if ("childIds" in itemDataWithChildren && itemDataWithChildren.childIds?.length) {
@@ -60782,7 +60782,7 @@ class ForceGraphEngine {
60782
60782
  const dist = Math.sqrt(dx * dx + dy * dy) || 1;
60783
60783
  const maxDimA = Math.max(s1.w, s1.h);
60784
60784
  const maxDimB = Math.max(s2.w, s2.h);
60785
- const targetDist = (maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB);
60785
+ const targetDist = ((maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB)) * 1.5;
60786
60786
  const force = (dist - targetDist) * conf.FG_SPRING_K;
60787
60787
  const fx = dx / dist * force;
60788
60788
  const fy = dy / dist * force;
@@ -61672,11 +61672,14 @@ class Board {
61672
61672
  }
61673
61673
  const newMap = {};
61674
61674
  const childItemIds = new Set;
61675
+ const childToParent = new Map;
61675
61676
  for (const itemId in itemsMap) {
61676
61677
  const d = itemsMap[itemId];
61677
61678
  if (Array.isArray(d.childIds)) {
61678
- for (const cid of d.childIds)
61679
+ for (const cid of d.childIds) {
61679
61680
  childItemIds.add(cid);
61681
+ childToParent.set(cid, itemId);
61682
+ }
61680
61683
  }
61681
61684
  }
61682
61685
  console.log("[paste] childItemIds:", [...childItemIds]);
@@ -61758,7 +61761,28 @@ class Board {
61758
61761
  }
61759
61762
  }
61760
61763
  } else if (childItemIds.has(itemId)) {
61761
- console.log(`[paste] SKIP child ${itemData.itemType} ${itemId}: keeping local (${translateX},${translateY})`);
61764
+ const parentId = childToParent.get(itemId);
61765
+ const parentData = parentId ? itemsMap[parentId] : undefined;
61766
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
61767
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
61768
+ const parentNewTx = parentOrigTx - minX + x;
61769
+ const parentNewTy = parentOrigTy - minY + y;
61770
+ const newChildTx = parentNewTx + translateX;
61771
+ const newChildTy = parentNewTy + translateY;
61772
+ console.log(`[paste] child ${itemData.itemType} ${itemId}: local=(${translateX},${translateY}) parentNew=(${parentNewTx},${parentNewTy}) → world=(${newChildTx},${newChildTy})`);
61773
+ if (itemData.transformation) {
61774
+ itemData.transformation.translateX = newChildTx;
61775
+ itemData.transformation.translateY = newChildTy;
61776
+ const d2 = itemData;
61777
+ if (d2.text && typeof d2.text === "object") {
61778
+ const textData = d2.text;
61779
+ if (textData.transformation && typeof textData.transformation === "object") {
61780
+ const tt = textData.transformation;
61781
+ tt.translateX = newChildTx;
61782
+ tt.translateY = newChildTy;
61783
+ }
61784
+ }
61785
+ }
61762
61786
  }
61763
61787
  if (itemData.itemType !== "RichText" && "childIds" in itemData && itemData.childIds?.length) {
61764
61788
  const itemDataWithChildren = itemData;
@@ -61840,9 +61864,22 @@ class Board {
61840
61864
  }
61841
61865
  }
61842
61866
  const newMap = {};
61867
+ const dupChildItemIds = new Set;
61868
+ const dupChildToParent = new Map;
61869
+ for (const itemId in itemsMap) {
61870
+ const d = itemsMap[itemId];
61871
+ if (Array.isArray(d.childIds)) {
61872
+ for (const cid of d.childIds) {
61873
+ dupChildItemIds.add(cid);
61874
+ dupChildToParent.set(cid, itemId);
61875
+ }
61876
+ }
61877
+ }
61843
61878
  let minX = Infinity;
61844
61879
  let minY = Infinity;
61845
61880
  for (const itemId in itemsMap) {
61881
+ if (dupChildItemIds.has(itemId))
61882
+ continue;
61846
61883
  const itemData = itemsMap[itemId];
61847
61884
  const { translateX, translateY } = itemData.transformation || {
61848
61885
  translateX: 0,
@@ -61888,6 +61925,28 @@ class Board {
61888
61925
  itemData.middlePoint.x += -minX + right + width2;
61889
61926
  itemData.middlePoint.y += -minY + top;
61890
61927
  }
61928
+ } else if (dupChildItemIds.has(itemId)) {
61929
+ const parentId = dupChildToParent.get(itemId);
61930
+ const parentData = parentId ? itemsMap[parentId] : undefined;
61931
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
61932
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
61933
+ const parentNewTx = parentOrigTx - minX + right + width2;
61934
+ const parentNewTy = parentOrigTy - minY + top;
61935
+ if (itemData.transformation) {
61936
+ const newChildTx = parentNewTx + translateX;
61937
+ const newChildTy = parentNewTy + translateY;
61938
+ itemData.transformation.translateX = newChildTx;
61939
+ itemData.transformation.translateY = newChildTy;
61940
+ itemData.transformation.isLocked = false;
61941
+ const d2 = itemData;
61942
+ if (d2.text && typeof d2.text === "object") {
61943
+ const tt = d2.text.transformation;
61944
+ if (tt) {
61945
+ tt.translateX = newChildTx;
61946
+ tt.translateY = newChildTy;
61947
+ }
61948
+ }
61949
+ }
61891
61950
  } else if (itemData.transformation) {
61892
61951
  itemData.transformation.translateX = translateX - minX + right + width2;
61893
61952
  itemData.transformation.translateY = translateY - minY + top;
@@ -61898,6 +61957,14 @@ class Board {
61898
61957
  if (height3 === 0 || isSelectedItemsMinWidth) {
61899
61958
  itemData.transformation.translateX = translateX + width2 * 10 + 10;
61900
61959
  }
61960
+ const d2 = itemData;
61961
+ if (d2.text && typeof d2.text === "object") {
61962
+ const tt = d2.text.transformation;
61963
+ if (tt) {
61964
+ tt.translateX = itemData.transformation.translateX;
61965
+ tt.translateY = itemData.transformation.translateY;
61966
+ }
61967
+ }
61901
61968
  }
61902
61969
  const itemDataWithChildren = itemData;
61903
61970
  if ("childIds" in itemDataWithChildren && itemDataWithChildren.childIds?.length) {
package/dist/esm/index.js CHANGED
@@ -60775,7 +60775,7 @@ class ForceGraphEngine {
60775
60775
  const dist = Math.sqrt(dx * dx + dy * dy) || 1;
60776
60776
  const maxDimA = Math.max(s1.w, s1.h);
60777
60777
  const maxDimB = Math.max(s2.w, s2.h);
60778
- const targetDist = (maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB);
60778
+ const targetDist = ((maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB)) * 1.5;
60779
60779
  const force = (dist - targetDist) * conf.FG_SPRING_K;
60780
60780
  const fx = dx / dist * force;
60781
60781
  const fy = dy / dist * force;
@@ -61665,11 +61665,14 @@ class Board {
61665
61665
  }
61666
61666
  const newMap = {};
61667
61667
  const childItemIds = new Set;
61668
+ const childToParent = new Map;
61668
61669
  for (const itemId in itemsMap) {
61669
61670
  const d = itemsMap[itemId];
61670
61671
  if (Array.isArray(d.childIds)) {
61671
- for (const cid of d.childIds)
61672
+ for (const cid of d.childIds) {
61672
61673
  childItemIds.add(cid);
61674
+ childToParent.set(cid, itemId);
61675
+ }
61673
61676
  }
61674
61677
  }
61675
61678
  console.log("[paste] childItemIds:", [...childItemIds]);
@@ -61751,7 +61754,28 @@ class Board {
61751
61754
  }
61752
61755
  }
61753
61756
  } else if (childItemIds.has(itemId)) {
61754
- console.log(`[paste] SKIP child ${itemData.itemType} ${itemId}: keeping local (${translateX},${translateY})`);
61757
+ const parentId = childToParent.get(itemId);
61758
+ const parentData = parentId ? itemsMap[parentId] : undefined;
61759
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
61760
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
61761
+ const parentNewTx = parentOrigTx - minX + x;
61762
+ const parentNewTy = parentOrigTy - minY + y;
61763
+ const newChildTx = parentNewTx + translateX;
61764
+ const newChildTy = parentNewTy + translateY;
61765
+ console.log(`[paste] child ${itemData.itemType} ${itemId}: local=(${translateX},${translateY}) parentNew=(${parentNewTx},${parentNewTy}) → world=(${newChildTx},${newChildTy})`);
61766
+ if (itemData.transformation) {
61767
+ itemData.transformation.translateX = newChildTx;
61768
+ itemData.transformation.translateY = newChildTy;
61769
+ const d2 = itemData;
61770
+ if (d2.text && typeof d2.text === "object") {
61771
+ const textData = d2.text;
61772
+ if (textData.transformation && typeof textData.transformation === "object") {
61773
+ const tt = textData.transformation;
61774
+ tt.translateX = newChildTx;
61775
+ tt.translateY = newChildTy;
61776
+ }
61777
+ }
61778
+ }
61755
61779
  }
61756
61780
  if (itemData.itemType !== "RichText" && "childIds" in itemData && itemData.childIds?.length) {
61757
61781
  const itemDataWithChildren = itemData;
@@ -61833,9 +61857,22 @@ class Board {
61833
61857
  }
61834
61858
  }
61835
61859
  const newMap = {};
61860
+ const dupChildItemIds = new Set;
61861
+ const dupChildToParent = new Map;
61862
+ for (const itemId in itemsMap) {
61863
+ const d = itemsMap[itemId];
61864
+ if (Array.isArray(d.childIds)) {
61865
+ for (const cid of d.childIds) {
61866
+ dupChildItemIds.add(cid);
61867
+ dupChildToParent.set(cid, itemId);
61868
+ }
61869
+ }
61870
+ }
61836
61871
  let minX = Infinity;
61837
61872
  let minY = Infinity;
61838
61873
  for (const itemId in itemsMap) {
61874
+ if (dupChildItemIds.has(itemId))
61875
+ continue;
61839
61876
  const itemData = itemsMap[itemId];
61840
61877
  const { translateX, translateY } = itemData.transformation || {
61841
61878
  translateX: 0,
@@ -61881,6 +61918,28 @@ class Board {
61881
61918
  itemData.middlePoint.x += -minX + right + width2;
61882
61919
  itemData.middlePoint.y += -minY + top;
61883
61920
  }
61921
+ } else if (dupChildItemIds.has(itemId)) {
61922
+ const parentId = dupChildToParent.get(itemId);
61923
+ const parentData = parentId ? itemsMap[parentId] : undefined;
61924
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
61925
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
61926
+ const parentNewTx = parentOrigTx - minX + right + width2;
61927
+ const parentNewTy = parentOrigTy - minY + top;
61928
+ if (itemData.transformation) {
61929
+ const newChildTx = parentNewTx + translateX;
61930
+ const newChildTy = parentNewTy + translateY;
61931
+ itemData.transformation.translateX = newChildTx;
61932
+ itemData.transformation.translateY = newChildTy;
61933
+ itemData.transformation.isLocked = false;
61934
+ const d2 = itemData;
61935
+ if (d2.text && typeof d2.text === "object") {
61936
+ const tt = d2.text.transformation;
61937
+ if (tt) {
61938
+ tt.translateX = newChildTx;
61939
+ tt.translateY = newChildTy;
61940
+ }
61941
+ }
61942
+ }
61884
61943
  } else if (itemData.transformation) {
61885
61944
  itemData.transformation.translateX = translateX - minX + right + width2;
61886
61945
  itemData.transformation.translateY = translateY - minY + top;
@@ -61891,6 +61950,14 @@ class Board {
61891
61950
  if (height3 === 0 || isSelectedItemsMinWidth) {
61892
61951
  itemData.transformation.translateX = translateX + width2 * 10 + 10;
61893
61952
  }
61953
+ const d2 = itemData;
61954
+ if (d2.text && typeof d2.text === "object") {
61955
+ const tt = d2.text.transformation;
61956
+ if (tt) {
61957
+ tt.translateX = itemData.transformation.translateX;
61958
+ tt.translateY = itemData.transformation.translateY;
61959
+ }
61960
+ }
61894
61961
  }
61895
61962
  const itemDataWithChildren = itemData;
61896
61963
  if ("childIds" in itemDataWithChildren && itemDataWithChildren.childIds?.length) {
package/dist/esm/node.js CHANGED
@@ -63239,7 +63239,7 @@ class ForceGraphEngine {
63239
63239
  const dist = Math.sqrt(dx * dx + dy * dy) || 1;
63240
63240
  const maxDimA = Math.max(s1.w, s1.h);
63241
63241
  const maxDimB = Math.max(s2.w, s2.h);
63242
- const targetDist = (maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB);
63242
+ const targetDist = ((maxDimA + maxDimB) * 0.5 + Math.max(maxDimA, maxDimB)) * 1.5;
63243
63243
  const force = (dist - targetDist) * conf.FG_SPRING_K;
63244
63244
  const fx = dx / dist * force;
63245
63245
  const fy = dy / dist * force;
@@ -64129,11 +64129,14 @@ class Board {
64129
64129
  }
64130
64130
  const newMap = {};
64131
64131
  const childItemIds = new Set;
64132
+ const childToParent = new Map;
64132
64133
  for (const itemId in itemsMap) {
64133
64134
  const d = itemsMap[itemId];
64134
64135
  if (Array.isArray(d.childIds)) {
64135
- for (const cid of d.childIds)
64136
+ for (const cid of d.childIds) {
64136
64137
  childItemIds.add(cid);
64138
+ childToParent.set(cid, itemId);
64139
+ }
64137
64140
  }
64138
64141
  }
64139
64142
  console.log("[paste] childItemIds:", [...childItemIds]);
@@ -64215,7 +64218,28 @@ class Board {
64215
64218
  }
64216
64219
  }
64217
64220
  } else if (childItemIds.has(itemId)) {
64218
- console.log(`[paste] SKIP child ${itemData.itemType} ${itemId}: keeping local (${translateX},${translateY})`);
64221
+ const parentId = childToParent.get(itemId);
64222
+ const parentData = parentId ? itemsMap[parentId] : undefined;
64223
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
64224
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
64225
+ const parentNewTx = parentOrigTx - minX + x;
64226
+ const parentNewTy = parentOrigTy - minY + y;
64227
+ const newChildTx = parentNewTx + translateX;
64228
+ const newChildTy = parentNewTy + translateY;
64229
+ console.log(`[paste] child ${itemData.itemType} ${itemId}: local=(${translateX},${translateY}) parentNew=(${parentNewTx},${parentNewTy}) → world=(${newChildTx},${newChildTy})`);
64230
+ if (itemData.transformation) {
64231
+ itemData.transformation.translateX = newChildTx;
64232
+ itemData.transformation.translateY = newChildTy;
64233
+ const d2 = itemData;
64234
+ if (d2.text && typeof d2.text === "object") {
64235
+ const textData = d2.text;
64236
+ if (textData.transformation && typeof textData.transformation === "object") {
64237
+ const tt = textData.transformation;
64238
+ tt.translateX = newChildTx;
64239
+ tt.translateY = newChildTy;
64240
+ }
64241
+ }
64242
+ }
64219
64243
  }
64220
64244
  if (itemData.itemType !== "RichText" && "childIds" in itemData && itemData.childIds?.length) {
64221
64245
  const itemDataWithChildren = itemData;
@@ -64297,9 +64321,22 @@ class Board {
64297
64321
  }
64298
64322
  }
64299
64323
  const newMap = {};
64324
+ const dupChildItemIds = new Set;
64325
+ const dupChildToParent = new Map;
64326
+ for (const itemId in itemsMap) {
64327
+ const d = itemsMap[itemId];
64328
+ if (Array.isArray(d.childIds)) {
64329
+ for (const cid of d.childIds) {
64330
+ dupChildItemIds.add(cid);
64331
+ dupChildToParent.set(cid, itemId);
64332
+ }
64333
+ }
64334
+ }
64300
64335
  let minX = Infinity;
64301
64336
  let minY = Infinity;
64302
64337
  for (const itemId in itemsMap) {
64338
+ if (dupChildItemIds.has(itemId))
64339
+ continue;
64303
64340
  const itemData = itemsMap[itemId];
64304
64341
  const { translateX, translateY } = itemData.transformation || {
64305
64342
  translateX: 0,
@@ -64345,6 +64382,28 @@ class Board {
64345
64382
  itemData.middlePoint.x += -minX + right + width2;
64346
64383
  itemData.middlePoint.y += -minY + top;
64347
64384
  }
64385
+ } else if (dupChildItemIds.has(itemId)) {
64386
+ const parentId = dupChildToParent.get(itemId);
64387
+ const parentData = parentId ? itemsMap[parentId] : undefined;
64388
+ const parentOrigTx = parentData?.transformation?.translateX ?? 0;
64389
+ const parentOrigTy = parentData?.transformation?.translateY ?? 0;
64390
+ const parentNewTx = parentOrigTx - minX + right + width2;
64391
+ const parentNewTy = parentOrigTy - minY + top;
64392
+ if (itemData.transformation) {
64393
+ const newChildTx = parentNewTx + translateX;
64394
+ const newChildTy = parentNewTy + translateY;
64395
+ itemData.transformation.translateX = newChildTx;
64396
+ itemData.transformation.translateY = newChildTy;
64397
+ itemData.transformation.isLocked = false;
64398
+ const d2 = itemData;
64399
+ if (d2.text && typeof d2.text === "object") {
64400
+ const tt = d2.text.transformation;
64401
+ if (tt) {
64402
+ tt.translateX = newChildTx;
64403
+ tt.translateY = newChildTy;
64404
+ }
64405
+ }
64406
+ }
64348
64407
  } else if (itemData.transformation) {
64349
64408
  itemData.transformation.translateX = translateX - minX + right + width2;
64350
64409
  itemData.transformation.translateY = translateY - minY + top;
@@ -64355,6 +64414,14 @@ class Board {
64355
64414
  if (height3 === 0 || isSelectedItemsMinWidth) {
64356
64415
  itemData.transformation.translateX = translateX + width2 * 10 + 10;
64357
64416
  }
64417
+ const d2 = itemData;
64418
+ if (d2.text && typeof d2.text === "object") {
64419
+ const tt = d2.text.transformation;
64420
+ if (tt) {
64421
+ tt.translateX = itemData.transformation.translateX;
64422
+ tt.translateY = itemData.transformation.translateY;
64423
+ }
64424
+ }
64358
64425
  }
64359
64426
  const itemDataWithChildren = itemData;
64360
64427
  if ("childIds" in itemDataWithChildren && itemDataWithChildren.childIds?.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.66",
3
+ "version": "0.13.68",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",