@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.
@@ -13020,7 +13020,14 @@ const PageCanvas = react.forwardRef(
13020
13020
  pendingGroupDrillInRef.current = null;
13021
13021
  } else if (drillGroup && !drillGroup.backgroundColor && !targetIsInCrop && alreadyThisGroup && !isMultiSelectKey && effectiveTarget !== activeNow) {
13022
13022
  pendingGroupPromotionRef.current = null;
13023
- pendingGroupDrillInRef.current = { groupId: drillGroup.id, childId: effectiveTargetId, target: effectiveTarget };
13023
+ const pointer = fabricCanvas.getPointer(opt.e);
13024
+ pendingGroupDrillInRef.current = {
13025
+ groupId: drillGroup.id,
13026
+ childId: effectiveTargetId,
13027
+ target: effectiveTarget,
13028
+ startX: pointer.x,
13029
+ startY: pointer.y
13030
+ };
13024
13031
  if (effectiveTarget instanceof fabric__namespace.Textbox) {
13025
13032
  suppressTextEditForClick(effectiveTarget);
13026
13033
  }
@@ -13167,7 +13174,7 @@ const PageCanvas = react.forwardRef(
13167
13174
  o.__lockScaleDuringCrop = false;
13168
13175
  });
13169
13176
  fabricCanvas.on("mouse:up", (e) => {
13170
- var _a2, _b2, _c;
13177
+ var _a2, _b2, _c, _d;
13171
13178
  clearTransforming();
13172
13179
  setGuides([]);
13173
13180
  setRotationLabel(null);
@@ -13177,7 +13184,21 @@ const PageCanvas = react.forwardRef(
13177
13184
  dragStarted = false;
13178
13185
  const pendingDrillIn = pendingGroupDrillInRef.current;
13179
13186
  pendingGroupDrillInRef.current = null;
13180
- if (pendingDrillIn && didTransformRef.current) {
13187
+ let movedPendingDrillPointer = false;
13188
+ if (pendingDrillIn && pendingDrillIn.startX !== void 0 && pendingDrillIn.startY !== void 0) {
13189
+ try {
13190
+ const pointer = fabricCanvas.getPointer(e == null ? void 0 : e.e);
13191
+ const zoom3 = ((_a2 = fabricCanvas.getZoom) == null ? void 0 : _a2.call(fabricCanvas)) || 1;
13192
+ const dragThreshold = Math.max(2, 4 / zoom3);
13193
+ movedPendingDrillPointer = Math.hypot(pointer.x - pendingDrillIn.startX, pointer.y - pendingDrillIn.startY) > dragThreshold;
13194
+ } catch {
13195
+ movedPendingDrillPointer = false;
13196
+ }
13197
+ }
13198
+ if (movedPendingDrillPointer) {
13199
+ didTransformRef.current = true;
13200
+ }
13201
+ if (pendingDrillIn && (didTransformRef.current || movedPendingDrillPointer)) {
13181
13202
  const activeNow = fabricCanvas.getActiveObject();
13182
13203
  fabricCanvas.__activeEditingGroupId = null;
13183
13204
  setDrilledGroupBounds(null);
@@ -13207,7 +13228,7 @@ const PageCanvas = react.forwardRef(
13207
13228
  fabricCanvas.__activeEditingGroupId = pendingDrillIn.groupId;
13208
13229
  delete pendingDrillIn.target.__pixldocsGroupSelection;
13209
13230
  delete pendingDrillIn.target.__pixldocsLogicalGroupIds;
13210
- (_b2 = (_a2 = pendingDrillIn.target).set) == null ? void 0 : _b2.call(_a2, { selectable: true, evented: true, hasBorders: true, hasControls: true });
13231
+ (_c = (_b2 = pendingDrillIn.target).set) == null ? void 0 : _c.call(_b2, { selectable: true, evented: true, hasBorders: true, hasControls: true });
13211
13232
  fabricCanvas.setActiveObject(pendingDrillIn.target);
13212
13233
  pendingDrillIn.target.setCoords();
13213
13234
  if (pendingDrillIn.target instanceof fabric__namespace.Textbox) {
@@ -13260,7 +13281,7 @@ const PageCanvas = react.forwardRef(
13260
13281
  }
13261
13282
  }
13262
13283
  const activeObj = fabricCanvas.getActiveObject();
13263
- if (activeObj && (activeObj.__cropGroup || ((_c = activeObj._ct) == null ? void 0 : _c.isCropGroup))) {
13284
+ if (activeObj && (activeObj.__cropGroup || ((_d = activeObj._ct) == null ? void 0 : _d.isCropGroup))) {
13264
13285
  activeObj.__lockScaleDuringCrop = false;
13265
13286
  if (activeObj.__cropDrag) {
13266
13287
  delete activeObj.__cropDrag;
@@ -13278,7 +13299,9 @@ const PageCanvas = react.forwardRef(
13278
13299
  syncLockedRef.current = false;
13279
13300
  }, 50);
13280
13301
  }
13281
- didTransformRef.current = false;
13302
+ requestAnimationFrame(() => {
13303
+ didTransformRef.current = false;
13304
+ });
13282
13305
  setTimeout(() => {
13283
13306
  if (!fabricCanvas._currentTransform) {
13284
13307
  editLockRef.current = false;
@@ -13806,19 +13829,26 @@ const PageCanvas = react.forwardRef(
13806
13829
  const activeDuringMove = fabricCanvas.getActiveObject();
13807
13830
  const movingLogicalGroupId = activeDuringMove instanceof fabric__namespace.ActiveSelection ? activeDuringMove.__pixldocsGroupSelection : void 0;
13808
13831
  const pendingMoveDrill = pendingGroupDrillInRef.current;
13832
+ const groupIdToKeep = movingLogicalGroupId ?? (pendingMoveDrill == null ? void 0 : pendingMoveDrill.groupId);
13809
13833
  if (movingLogicalGroupId || pendingMoveDrill) {
13810
- const groupIdToKeep = movingLogicalGroupId ?? (pendingMoveDrill == null ? void 0 : pendingMoveDrill.groupId);
13811
13834
  pendingGroupDrillInRef.current = null;
13812
13835
  fabricCanvas.__activeEditingGroupId = null;
13813
13836
  setDrilledGroupBounds(null);
13814
13837
  drilledGroupIdRef.current = null;
13815
13838
  if (activeDuringMove instanceof fabric__namespace.ActiveSelection && groupIdToKeep) {
13816
13839
  restoreGroupSelectionVisualState(activeDuringMove, groupIdToKeep);
13840
+ const memberIds = activeDuringMove.getObjects().map((obj2) => getObjectId(obj2)).filter((id) => !!id && id !== "__background__");
13841
+ if (memberIds.length > 1) {
13842
+ preserveActiveSelectionAfterTransformRef.current = { memberIds, groupSelectionId: groupIdToKeep, expiresAt: Date.now() + 1200 };
13843
+ }
13844
+ preserveSelectionAfterTransformIdRef.current = groupIdToKeep;
13817
13845
  }
13818
13846
  }
13819
13847
  if (e.target) e.target.__pixldocsDragMoved = true;
13820
13848
  const moveTargetId = e.target ? getObjectId(e.target) : null;
13821
- if (moveTargetId && moveTargetId !== "__background__") {
13849
+ if (groupIdToKeep) {
13850
+ preserveSelectionAfterTransformIdRef.current = groupIdToKeep;
13851
+ } else if (moveTargetId && moveTargetId !== "__background__") {
13822
13852
  preserveSelectionAfterTransformIdRef.current = moveTargetId;
13823
13853
  }
13824
13854
  if (!dragStarted) {
@@ -14273,12 +14303,18 @@ const PageCanvas = react.forwardRef(
14273
14303
  const newTop = (groupToMove.top ?? 0) + deltaY;
14274
14304
  updateNodeStore(groupToMove.id, { left: newLeft, top: newTop }, { recordHistory: false, skipLayoutRecalc: true });
14275
14305
  commitHistoryStore();
14306
+ pendingGroupDrillInRef.current = null;
14307
+ fabricCanvas.__activeEditingGroupId = null;
14308
+ setDrilledGroupBounds(null);
14309
+ drilledGroupIdRef.current = null;
14276
14310
  const groupSelectionId = (isActiveSelection && activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.__pixldocsGroupSelection : void 0) ?? groupToMove.id;
14277
14311
  const targetObjects = isActiveSelection && activeObj instanceof fabric__namespace.ActiveSelection ? activeObj.getObjects() : activeObjects;
14278
14312
  if (groupSelectionId && activeObj instanceof fabric__namespace.ActiveSelection) {
14279
14313
  restoreGroupSelectionVisualState(activeObj, groupSelectionId);
14314
+ fabricCanvas.setActiveObject(activeObj);
14280
14315
  activeObj.setCoords();
14281
14316
  }
14317
+ selectElements([groupSelectionId], false, false);
14282
14318
  fabricCanvas.requestRenderAll();
14283
14319
  elementsRef.current = getCurrentElements();
14284
14320
  for (const obj of targetObjects) {
@@ -23617,9 +23653,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23617
23653
  }
23618
23654
  return svgString;
23619
23655
  }
23620
- const resolvedPackageVersion = "0.5.264";
23656
+ const resolvedPackageVersion = "0.5.266";
23621
23657
  const PACKAGE_VERSION = resolvedPackageVersion;
23622
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.264";
23658
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.266";
23623
23659
  const roundParityValue = (value) => {
23624
23660
  if (typeof value !== "number") return value;
23625
23661
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24433,7 +24469,7 @@ class PixldocsRenderer {
24433
24469
  await this.waitForCanvasScene(container, cloned, i);
24434
24470
  }
24435
24471
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24436
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DFWs6eXH.cjs"));
24472
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-i1DTwWah.cjs"));
24437
24473
  const prepared = preparePagesForExport(
24438
24474
  cloned.pages,
24439
24475
  canvasWidth,
@@ -26753,7 +26789,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26753
26789
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26754
26790
  sanitizeSvgTreeForPdf(svgToDraw);
26755
26791
  try {
26756
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DFWs6eXH.cjs"));
26792
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-i1DTwWah.cjs"));
26757
26793
  try {
26758
26794
  await logTextMeasurementDiagnostic(svgToDraw);
26759
26795
  } catch {
@@ -27150,4 +27186,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27150
27186
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27151
27187
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27152
27188
  exports.warmTemplateFromForm = warmTemplateFromForm;
27153
- //# sourceMappingURL=index-D_rGYvZm.cjs.map
27189
+ //# sourceMappingURL=index-BTlyH7B1.cjs.map