@pixldocs/canvas-renderer 0.5.264 → 0.5.266

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.
@@ -13002,7 +13002,14 @@ const PageCanvas = forwardRef(
13002
13002
  pendingGroupDrillInRef.current = null;
13003
13003
  } else if (drillGroup && !drillGroup.backgroundColor && !targetIsInCrop && alreadyThisGroup && !isMultiSelectKey && effectiveTarget !== activeNow) {
13004
13004
  pendingGroupPromotionRef.current = null;
13005
- pendingGroupDrillInRef.current = { groupId: drillGroup.id, childId: effectiveTargetId, target: effectiveTarget };
13005
+ const pointer = fabricCanvas.getPointer(opt.e);
13006
+ pendingGroupDrillInRef.current = {
13007
+ groupId: drillGroup.id,
13008
+ childId: effectiveTargetId,
13009
+ target: effectiveTarget,
13010
+ startX: pointer.x,
13011
+ startY: pointer.y
13012
+ };
13006
13013
  if (effectiveTarget instanceof fabric.Textbox) {
13007
13014
  suppressTextEditForClick(effectiveTarget);
13008
13015
  }
@@ -13149,7 +13156,7 @@ const PageCanvas = forwardRef(
13149
13156
  o.__lockScaleDuringCrop = false;
13150
13157
  });
13151
13158
  fabricCanvas.on("mouse:up", (e) => {
13152
- var _a2, _b2, _c;
13159
+ var _a2, _b2, _c, _d;
13153
13160
  clearTransforming();
13154
13161
  setGuides([]);
13155
13162
  setRotationLabel(null);
@@ -13159,7 +13166,21 @@ const PageCanvas = forwardRef(
13159
13166
  dragStarted = false;
13160
13167
  const pendingDrillIn = pendingGroupDrillInRef.current;
13161
13168
  pendingGroupDrillInRef.current = null;
13162
- if (pendingDrillIn && didTransformRef.current) {
13169
+ let movedPendingDrillPointer = false;
13170
+ if (pendingDrillIn && pendingDrillIn.startX !== void 0 && pendingDrillIn.startY !== void 0) {
13171
+ try {
13172
+ const pointer = fabricCanvas.getPointer(e == null ? void 0 : e.e);
13173
+ const zoom3 = ((_a2 = fabricCanvas.getZoom) == null ? void 0 : _a2.call(fabricCanvas)) || 1;
13174
+ const dragThreshold = Math.max(2, 4 / zoom3);
13175
+ movedPendingDrillPointer = Math.hypot(pointer.x - pendingDrillIn.startX, pointer.y - pendingDrillIn.startY) > dragThreshold;
13176
+ } catch {
13177
+ movedPendingDrillPointer = false;
13178
+ }
13179
+ }
13180
+ if (movedPendingDrillPointer) {
13181
+ didTransformRef.current = true;
13182
+ }
13183
+ if (pendingDrillIn && (didTransformRef.current || movedPendingDrillPointer)) {
13163
13184
  const activeNow = fabricCanvas.getActiveObject();
13164
13185
  fabricCanvas.__activeEditingGroupId = null;
13165
13186
  setDrilledGroupBounds(null);
@@ -13189,7 +13210,7 @@ const PageCanvas = forwardRef(
13189
13210
  fabricCanvas.__activeEditingGroupId = pendingDrillIn.groupId;
13190
13211
  delete pendingDrillIn.target.__pixldocsGroupSelection;
13191
13212
  delete pendingDrillIn.target.__pixldocsLogicalGroupIds;
13192
- (_b2 = (_a2 = pendingDrillIn.target).set) == null ? void 0 : _b2.call(_a2, { selectable: true, evented: true, hasBorders: true, hasControls: true });
13213
+ (_c = (_b2 = pendingDrillIn.target).set) == null ? void 0 : _c.call(_b2, { selectable: true, evented: true, hasBorders: true, hasControls: true });
13193
13214
  fabricCanvas.setActiveObject(pendingDrillIn.target);
13194
13215
  pendingDrillIn.target.setCoords();
13195
13216
  if (pendingDrillIn.target instanceof fabric.Textbox) {
@@ -13242,7 +13263,7 @@ const PageCanvas = forwardRef(
13242
13263
  }
13243
13264
  }
13244
13265
  const activeObj = fabricCanvas.getActiveObject();
13245
- if (activeObj && (activeObj.__cropGroup || ((_c = activeObj._ct) == null ? void 0 : _c.isCropGroup))) {
13266
+ if (activeObj && (activeObj.__cropGroup || ((_d = activeObj._ct) == null ? void 0 : _d.isCropGroup))) {
13246
13267
  activeObj.__lockScaleDuringCrop = false;
13247
13268
  if (activeObj.__cropDrag) {
13248
13269
  delete activeObj.__cropDrag;
@@ -13260,7 +13281,9 @@ const PageCanvas = forwardRef(
13260
13281
  syncLockedRef.current = false;
13261
13282
  }, 50);
13262
13283
  }
13263
- didTransformRef.current = false;
13284
+ requestAnimationFrame(() => {
13285
+ didTransformRef.current = false;
13286
+ });
13264
13287
  setTimeout(() => {
13265
13288
  if (!fabricCanvas._currentTransform) {
13266
13289
  editLockRef.current = false;
@@ -13788,19 +13811,26 @@ const PageCanvas = forwardRef(
13788
13811
  const activeDuringMove = fabricCanvas.getActiveObject();
13789
13812
  const movingLogicalGroupId = activeDuringMove instanceof fabric.ActiveSelection ? activeDuringMove.__pixldocsGroupSelection : void 0;
13790
13813
  const pendingMoveDrill = pendingGroupDrillInRef.current;
13814
+ const groupIdToKeep = movingLogicalGroupId ?? (pendingMoveDrill == null ? void 0 : pendingMoveDrill.groupId);
13791
13815
  if (movingLogicalGroupId || pendingMoveDrill) {
13792
- const groupIdToKeep = movingLogicalGroupId ?? (pendingMoveDrill == null ? void 0 : pendingMoveDrill.groupId);
13793
13816
  pendingGroupDrillInRef.current = null;
13794
13817
  fabricCanvas.__activeEditingGroupId = null;
13795
13818
  setDrilledGroupBounds(null);
13796
13819
  drilledGroupIdRef.current = null;
13797
13820
  if (activeDuringMove instanceof fabric.ActiveSelection && groupIdToKeep) {
13798
13821
  restoreGroupSelectionVisualState(activeDuringMove, groupIdToKeep);
13822
+ const memberIds = activeDuringMove.getObjects().map((obj2) => getObjectId(obj2)).filter((id) => !!id && id !== "__background__");
13823
+ if (memberIds.length > 1) {
13824
+ preserveActiveSelectionAfterTransformRef.current = { memberIds, groupSelectionId: groupIdToKeep, expiresAt: Date.now() + 1200 };
13825
+ }
13826
+ preserveSelectionAfterTransformIdRef.current = groupIdToKeep;
13799
13827
  }
13800
13828
  }
13801
13829
  if (e.target) e.target.__pixldocsDragMoved = true;
13802
13830
  const moveTargetId = e.target ? getObjectId(e.target) : null;
13803
- if (moveTargetId && moveTargetId !== "__background__") {
13831
+ if (groupIdToKeep) {
13832
+ preserveSelectionAfterTransformIdRef.current = groupIdToKeep;
13833
+ } else if (moveTargetId && moveTargetId !== "__background__") {
13804
13834
  preserveSelectionAfterTransformIdRef.current = moveTargetId;
13805
13835
  }
13806
13836
  if (!dragStarted) {
@@ -14255,12 +14285,18 @@ const PageCanvas = forwardRef(
14255
14285
  const newTop = (groupToMove.top ?? 0) + deltaY;
14256
14286
  updateNodeStore(groupToMove.id, { left: newLeft, top: newTop }, { recordHistory: false, skipLayoutRecalc: true });
14257
14287
  commitHistoryStore();
14288
+ pendingGroupDrillInRef.current = null;
14289
+ fabricCanvas.__activeEditingGroupId = null;
14290
+ setDrilledGroupBounds(null);
14291
+ drilledGroupIdRef.current = null;
14258
14292
  const groupSelectionId = (isActiveSelection && activeObj instanceof fabric.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0) ?? groupToMove.id;
14259
14293
  const targetObjects = isActiveSelection && activeObj instanceof fabric.ActiveSelection ? activeObj.getObjects() : activeObjects;
14260
14294
  if (groupSelectionId && activeObj instanceof fabric.ActiveSelection) {
14261
14295
  restoreGroupSelectionVisualState(activeObj, groupSelectionId);
14296
+ fabricCanvas.setActiveObject(activeObj);
14262
14297
  activeObj.setCoords();
14263
14298
  }
14299
+ selectElements([groupSelectionId], false, false);
14264
14300
  fabricCanvas.requestRenderAll();
14265
14301
  elementsRef.current = getCurrentElements();
14266
14302
  for (const obj of targetObjects) {
@@ -23599,9 +23635,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23599
23635
  }
23600
23636
  return svgString;
23601
23637
  }
23602
- const resolvedPackageVersion = "0.5.264";
23638
+ const resolvedPackageVersion = "0.5.266";
23603
23639
  const PACKAGE_VERSION = resolvedPackageVersion;
23604
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.264";
23640
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.266";
23605
23641
  const roundParityValue = (value) => {
23606
23642
  if (typeof value !== "number") return value;
23607
23643
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24415,7 +24451,7 @@ class PixldocsRenderer {
24415
24451
  await this.waitForCanvasScene(container, cloned, i);
24416
24452
  }
24417
24453
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24418
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BYAVxEPn.js");
24454
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CO8Kr9ha.js");
24419
24455
  const prepared = preparePagesForExport(
24420
24456
  cloned.pages,
24421
24457
  canvasWidth,
@@ -26735,7 +26771,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26735
26771
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26736
26772
  sanitizeSvgTreeForPdf(svgToDraw);
26737
26773
  try {
26738
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BYAVxEPn.js");
26774
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CO8Kr9ha.js");
26739
26775
  try {
26740
26776
  await logTextMeasurementDiagnostic(svgToDraw);
26741
26777
  } catch {
@@ -27135,4 +27171,4 @@ export {
27135
27171
  buildTeaserBlurFlatKeys as y,
27136
27172
  collectFontDescriptorsFromConfig as z
27137
27173
  };
27138
- //# sourceMappingURL=index-BG1PCSDy.js.map
27174
+ //# sourceMappingURL=index-Dno8Fb1D.js.map