@pixldocs/canvas-renderer 0.5.265 → 0.5.267

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) {
@@ -15371,9 +15401,9 @@ const PageCanvas = forwardRef(
15371
15401
  const currentVisible = element.visible !== false;
15372
15402
  const fabricLeft = existingObj.left ?? 0;
15373
15403
  const fabricTop = existingObj.top ?? 0;
15374
- const storePos = pageChildren ? (() => {
15375
- const node = findNodeById(pageChildren, element.id);
15376
- return node ? getAbsoluteBounds(node, pageChildren) : { left: element.left ?? 0, top: element.top ?? 0 };
15404
+ const storePos = pageTree.length ? (() => {
15405
+ const node = findNodeById(pageTree, element.id);
15406
+ return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15377
15407
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15378
15408
  const storeLeft = storePos.left;
15379
15409
  const storeTop = storePos.top;
@@ -15387,7 +15417,7 @@ const PageCanvas = forwardRef(
15387
15417
  if (positionChanged && isSelected && (wasJustModified || isBeingTransformed)) {
15388
15418
  positionChanged = false;
15389
15419
  }
15390
- const resolvedSizeForCompare = (pageChildren == null ? void 0 : pageChildren.length) ? getNodeBounds(element, pageChildren) : { width: typeof element.width === "number" ? element.width : 0, height: typeof element.height === "number" ? element.height : 0 };
15420
+ const resolvedSizeForCompare = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 0, height: typeof element.height === "number" ? element.height : 0 };
15391
15421
  const fabricText = existingObj.text ?? "";
15392
15422
  const storeText = element.text ?? "";
15393
15423
  const otherPropsChanged = Math.abs((existingObj.width ?? 0) - resolvedSizeForCompare.width) > 0.1 || Math.abs((existingObj.height ?? 0) - resolvedSizeForCompare.height) > 0.1 || Math.abs((existingObj.angle ?? 0) - (element.angle ?? 0)) > 0.1 || Math.abs((existingObj.scaleX ?? 1) - (element.scaleX ?? 1)) > 0.01 || Math.abs((existingObj.scaleY ?? 1) - (element.scaleY ?? 1)) > 0.01 || (existingObj.flipX ?? false) !== (element.flipX ?? false) || (existingObj.flipY ?? false) !== (element.flipY ?? false) || fabricText !== storeText || existingObj.fill !== (element.fill ?? "") || existingObj.stroke !== (element.stroke ?? "") || Math.abs((existingObj.strokeWidth ?? 0) - (element.strokeWidth ?? 0)) > 0.01 || Math.abs((existingObj.opacity ?? 1) - (element.opacity ?? 1)) > 0.01 || (existingObj.fontSize ?? 0) !== (element.fontSize ?? 0) || (existingObj.fontFamily ?? "") !== (element.fontFamily ?? "") || // Vertical alignment & min box height: panel-driven changes must trigger a re-apply
@@ -16027,7 +16057,7 @@ const PageCanvas = forwardRef(
16027
16057
  if (fc && isTransforming(fc)) {
16028
16058
  return;
16029
16059
  }
16030
- const currentPageTree = ((pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
16060
+ const currentPageTree = (isPreviewMode && (pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
16031
16061
  const fabricPos = currentPageTree.length > 0 ? (() => {
16032
16062
  const node = findNodeById(currentPageTree, element.id);
16033
16063
  return node ? getAbsoluteBounds(node, currentPageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
@@ -23605,9 +23635,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23605
23635
  }
23606
23636
  return svgString;
23607
23637
  }
23608
- const resolvedPackageVersion = "0.5.265";
23638
+ const resolvedPackageVersion = "0.5.267";
23609
23639
  const PACKAGE_VERSION = resolvedPackageVersion;
23610
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.265";
23640
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.267";
23611
23641
  const roundParityValue = (value) => {
23612
23642
  if (typeof value !== "number") return value;
23613
23643
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24421,7 +24451,7 @@ class PixldocsRenderer {
24421
24451
  await this.waitForCanvasScene(container, cloned, i);
24422
24452
  }
24423
24453
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24424
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-ONQJ99LA.js");
24454
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-ByDlpq77.js");
24425
24455
  const prepared = preparePagesForExport(
24426
24456
  cloned.pages,
24427
24457
  canvasWidth,
@@ -26741,7 +26771,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26741
26771
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26742
26772
  sanitizeSvgTreeForPdf(svgToDraw);
26743
26773
  try {
26744
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-ONQJ99LA.js");
26774
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-ByDlpq77.js");
26745
26775
  try {
26746
26776
  await logTextMeasurementDiagnostic(svgToDraw);
26747
26777
  } catch {
@@ -27141,4 +27171,4 @@ export {
27141
27171
  buildTeaserBlurFlatKeys as y,
27142
27172
  collectFontDescriptorsFromConfig as z
27143
27173
  };
27144
- //# sourceMappingURL=index-CO6jIEmB.js.map
27174
+ //# sourceMappingURL=index-BDPFvAqK.js.map