@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.
@@ -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) {
@@ -15389,9 +15419,9 @@ const PageCanvas = react.forwardRef(
15389
15419
  const currentVisible = element.visible !== false;
15390
15420
  const fabricLeft = existingObj.left ?? 0;
15391
15421
  const fabricTop = existingObj.top ?? 0;
15392
- const storePos = pageChildren ? (() => {
15393
- const node = findNodeById(pageChildren, element.id);
15394
- return node ? getAbsoluteBounds(node, pageChildren) : { left: element.left ?? 0, top: element.top ?? 0 };
15422
+ const storePos = pageTree.length ? (() => {
15423
+ const node = findNodeById(pageTree, element.id);
15424
+ return node ? getAbsoluteBounds(node, pageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
15395
15425
  })() : { left: element.left ?? 0, top: element.top ?? 0 };
15396
15426
  const storeLeft = storePos.left;
15397
15427
  const storeTop = storePos.top;
@@ -15405,7 +15435,7 @@ const PageCanvas = react.forwardRef(
15405
15435
  if (positionChanged && isSelected && (wasJustModified || isBeingTransformed)) {
15406
15436
  positionChanged = false;
15407
15437
  }
15408
- 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 };
15438
+ const resolvedSizeForCompare = pageTree.length ? getNodeBounds(element, pageTree) : { width: typeof element.width === "number" ? element.width : 0, height: typeof element.height === "number" ? element.height : 0 };
15409
15439
  const fabricText = existingObj.text ?? "";
15410
15440
  const storeText = element.text ?? "";
15411
15441
  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
@@ -16045,7 +16075,7 @@ const PageCanvas = react.forwardRef(
16045
16075
  if (fc && isTransforming(fc)) {
16046
16076
  return;
16047
16077
  }
16048
- const currentPageTree = ((pageChildren == null ? void 0 : pageChildren.length) ? pageChildren : (_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
16078
+ 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) ?? [];
16049
16079
  const fabricPos = currentPageTree.length > 0 ? (() => {
16050
16080
  const node = findNodeById(currentPageTree, element.id);
16051
16081
  return node ? getAbsoluteBounds(node, currentPageTree) : { left: element.left ?? 0, top: element.top ?? 0 };
@@ -23623,9 +23653,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23623
23653
  }
23624
23654
  return svgString;
23625
23655
  }
23626
- const resolvedPackageVersion = "0.5.265";
23656
+ const resolvedPackageVersion = "0.5.267";
23627
23657
  const PACKAGE_VERSION = resolvedPackageVersion;
23628
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.265";
23658
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.267";
23629
23659
  const roundParityValue = (value) => {
23630
23660
  if (typeof value !== "number") return value;
23631
23661
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24439,7 +24469,7 @@ class PixldocsRenderer {
24439
24469
  await this.waitForCanvasScene(container, cloned, i);
24440
24470
  }
24441
24471
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24442
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-C_SPH6M3.cjs"));
24472
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-vH_Qgwx6.cjs"));
24443
24473
  const prepared = preparePagesForExport(
24444
24474
  cloned.pages,
24445
24475
  canvasWidth,
@@ -26759,7 +26789,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26759
26789
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26760
26790
  sanitizeSvgTreeForPdf(svgToDraw);
26761
26791
  try {
26762
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-C_SPH6M3.cjs"));
26792
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-vH_Qgwx6.cjs"));
26763
26793
  try {
26764
26794
  await logTextMeasurementDiagnostic(svgToDraw);
26765
26795
  } catch {
@@ -27156,4 +27186,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
27156
27186
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
27157
27187
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
27158
27188
  exports.warmTemplateFromForm = warmTemplateFromForm;
27159
- //# sourceMappingURL=index-8qmW0_0N.cjs.map
27189
+ //# sourceMappingURL=index-C_tX_wMV.cjs.map