@pixldocs/canvas-renderer 0.5.243 → 0.5.244

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.
@@ -11194,6 +11194,7 @@ const PageCanvas = react.forwardRef(
11194
11194
  const preserveEditingScopeOnSelectionClearRef = react.useRef(false);
11195
11195
  const preserveActiveSelectionAfterTransformRef = react.useRef(null);
11196
11196
  const pendingGroupPromotionRef = react.useRef(null);
11197
+ const pendingGroupDrillInRef = react.useRef(null);
11197
11198
  const imageReloadRequestSeqRef = react.useRef(/* @__PURE__ */ new Map());
11198
11199
  react.useRef(null);
11199
11200
  const groupBoundsResizingRef = react.useRef(false);
@@ -12264,7 +12265,7 @@ const PageCanvas = react.forwardRef(
12264
12265
  const active = fabricCanvas.getActiveObject();
12265
12266
  let hitChild = null;
12266
12267
  if (active instanceof fabric__namespace.ActiveSelection) {
12267
- const pointer = fabricCanvas.getViewportPoint(opt.e);
12268
+ const pointer = fabricCanvas.getPointer(opt.e);
12268
12269
  const objs = active.getObjects();
12269
12270
  for (let i = objs.length - 1; i >= 0; i--) {
12270
12271
  const o = objs[i];
@@ -12485,10 +12486,36 @@ const PageCanvas = react.forwardRef(
12485
12486
  }
12486
12487
  };
12487
12488
  const isMultiSelectModifier = (event) => !!((event == null ? void 0 : event.shiftKey) || (event == null ? void 0 : event.metaKey) || (event == null ? void 0 : event.ctrlKey));
12489
+ const pickChildInActiveSelectionAtPointer = (selection, event) => {
12490
+ var _a2, _b2, _c, _d, _e;
12491
+ try {
12492
+ const pointer = fabricCanvas.getPointer(event);
12493
+ const viewportPointer = (_a2 = fabricCanvas.getViewportPoint) == null ? void 0 : _a2.call(fabricCanvas, event);
12494
+ const zoom3 = ((_b2 = fabricCanvas.getZoom) == null ? void 0 : _b2.call(fabricCanvas)) || 1;
12495
+ const tolerance = Math.max(3, 6 / zoom3);
12496
+ const members = selection.getObjects();
12497
+ for (let i = members.length - 1; i >= 0; i--) {
12498
+ const obj = members[i];
12499
+ const id = getObjectId(obj);
12500
+ if (!id || id === "__background__" || obj.visible === false) continue;
12501
+ (_c = obj.setCoords) == null ? void 0 : _c.call(obj);
12502
+ const containsScene = typeof obj.containsPoint === "function" && obj.containsPoint(pointer);
12503
+ const containsViewport = !!(viewportPointer && typeof obj.containsPoint === "function" && obj.containsPoint(viewportPointer));
12504
+ if (containsScene || containsViewport) return obj;
12505
+ const br = ((_d = obj.getBoundingRect) == null ? void 0 : _d.call(obj, true, true)) ?? ((_e = obj.getBoundingRect) == null ? void 0 : _e.call(obj));
12506
+ if (br && pointer.x >= br.left - tolerance && pointer.x <= br.left + br.width + tolerance && pointer.y >= br.top - tolerance && pointer.y <= br.top + br.height + tolerance) {
12507
+ return obj;
12508
+ }
12509
+ }
12510
+ } catch {
12511
+ return null;
12512
+ }
12513
+ return null;
12514
+ };
12488
12515
  const pickSelectableObjectAtPointer = (event) => {
12489
12516
  var _a2;
12490
12517
  try {
12491
- const pointer = fabricCanvas.getViewportPoint(event);
12518
+ const pointer = fabricCanvas.getPointer(event);
12492
12519
  const objects = fabricCanvas.getObjects();
12493
12520
  for (let i = objects.length - 1; i >= 0; i--) {
12494
12521
  const obj = objects[i];
@@ -12755,22 +12782,11 @@ const PageCanvas = react.forwardRef(
12755
12782
  let target = opt.target;
12756
12783
  let targetId = target ? getObjectId(target) : null;
12757
12784
  if (target instanceof fabric__namespace.ActiveSelection && target.__pixldocsGroupSelection && target === fabricCanvas.getActiveObject()) {
12758
- try {
12759
- const pointer = fabricCanvas.getViewportPoint(opt.e);
12760
- const members = target.getObjects();
12761
- for (let i = members.length - 1; i >= 0; i--) {
12762
- const m = members[i];
12763
- if (m.visible === false) continue;
12764
- if (typeof m.containsPoint === "function" && m.containsPoint(pointer)) {
12765
- const mid = getObjectId(m);
12766
- if (mid) {
12767
- target = m;
12768
- targetId = mid;
12769
- }
12770
- break;
12771
- }
12772
- }
12773
- } catch {
12785
+ const child = pickChildInActiveSelectionAtPointer(target, opt.e);
12786
+ const childId = child ? getObjectId(child) : null;
12787
+ if (child && childId) {
12788
+ target = child;
12789
+ targetId = childId;
12774
12790
  }
12775
12791
  }
12776
12792
  const activeEditingGroupId = fabricCanvas.__activeEditingGroupId ?? null;
@@ -12789,6 +12805,7 @@ const PageCanvas = react.forwardRef(
12789
12805
  activeObjects: fabricCanvas.getActiveObjects().slice()
12790
12806
  };
12791
12807
  pendingGroupPromotionRef.current = null;
12808
+ pendingGroupDrillInRef.current = null;
12792
12809
  return;
12793
12810
  }
12794
12811
  }
@@ -12811,28 +12828,21 @@ const PageCanvas = react.forwardRef(
12811
12828
  const activeNowEarly = fabricCanvas.getActiveObject();
12812
12829
  const asGroupId = target instanceof fabric__namespace.ActiveSelection ? target.__pixldocsGroupSelection : void 0;
12813
12830
  if (target instanceof fabric__namespace.ActiveSelection && asGroupId && target === activeNowEarly) {
12814
- try {
12815
- const pointer = fabricCanvas.getViewportPoint(opt.e);
12816
- const members = target.getObjects();
12817
- for (let i = members.length - 1; i >= 0; i--) {
12818
- const m = members[i];
12819
- if (m.visible === false) continue;
12820
- if (typeof m.containsPoint === "function" && m.containsPoint(pointer)) {
12821
- const mid = getObjectId(m);
12822
- if (mid) {
12823
- effectiveTarget = m;
12824
- effectiveTargetId = mid;
12825
- }
12826
- break;
12827
- }
12828
- }
12829
- } catch {
12831
+ const child = pickChildInActiveSelectionAtPointer(target, opt.e);
12832
+ const childId = child ? getObjectId(child) : null;
12833
+ if (child && childId) {
12834
+ effectiveTarget = child;
12835
+ effectiveTargetId = childId;
12830
12836
  }
12831
12837
  }
12832
12838
  const parent = findTopmostPromotableGroup(effectiveTargetId);
12833
12839
  const targetIsInCrop = !!(effectiveTarget instanceof fabric__namespace.Group && isCropGroupInCropMode(effectiveTarget) || (effectiveTarget == null ? void 0 : effectiveTarget.group) instanceof fabric__namespace.Group && isCropGroupInCropMode(effectiveTarget.group));
12834
12840
  const activeNow = fabricCanvas.getActiveObject();
12835
- const alreadyThisGroup = activeNow instanceof fabric__namespace.ActiveSelection && activeNow.__pixldocsGroupSelection === (parent == null ? void 0 : parent.id);
12841
+ const activeGroupSelectionId = activeNow instanceof fabric__namespace.ActiveSelection ? activeNow.__pixldocsGroupSelection : void 0;
12842
+ const activeGroupNode = activeGroupSelectionId ? findNodeById(childrenNow, activeGroupSelectionId) : null;
12843
+ const activeGroupContainsTarget = !!(activeGroupNode && isGroup(activeGroupNode) && getAllElementIds(activeGroupNode.children ?? []).includes(effectiveTargetId));
12844
+ const alreadyThisGroup = !!(activeGroupSelectionId && activeGroupContainsTarget);
12845
+ const drillGroup = alreadyThisGroup && activeGroupNode && isGroup(activeGroupNode) ? activeGroupNode : parent;
12836
12846
  const isMultiSelectKey = !!(((_f = opt.e) == null ? void 0 : _f.shiftKey) || ((_g = opt.e) == null ? void 0 : _g.metaKey) || ((_h = opt.e) == null ? void 0 : _h.ctrlKey));
12837
12847
  const isDeepSelectKey = !!((_i = opt.e) == null ? void 0 : _i.altKey);
12838
12848
  if (isDeepSelectKey) {
@@ -12862,7 +12872,8 @@ const PageCanvas = react.forwardRef(
12862
12872
  opt.target = only;
12863
12873
  pendingGroupPromotionRef.current = { groupId: parent.id, selection: only };
12864
12874
  }
12865
- } else if (parent && !parent.backgroundColor && !targetIsInCrop && alreadyThisGroup && !isMultiSelectKey && effectiveTarget !== activeNow) {
12875
+ pendingGroupDrillInRef.current = null;
12876
+ } else if (drillGroup && !drillGroup.backgroundColor && !targetIsInCrop && alreadyThisGroup && !isMultiSelectKey && effectiveTarget !== activeNow) {
12866
12877
  try {
12867
12878
  skipSelectionClearOnDiscardRef.current = true;
12868
12879
  preserveEditingScopeOnSelectionClearRef.current = true;
@@ -12872,7 +12883,7 @@ const PageCanvas = react.forwardRef(
12872
12883
  skipSelectionClearOnDiscardRef.current = false;
12873
12884
  preserveEditingScopeOnSelectionClearRef.current = false;
12874
12885
  }
12875
- fabricCanvas.__activeEditingGroupId = parent.id;
12886
+ fabricCanvas.__activeEditingGroupId = drillGroup.id;
12876
12887
  delete effectiveTarget.__pixldocsGroupSelection;
12877
12888
  delete effectiveTarget.__pixldocsLogicalGroupIds;
12878
12889
  try {
@@ -12884,6 +12895,9 @@ const PageCanvas = react.forwardRef(
12884
12895
  fabricCanvas._target = effectiveTarget;
12885
12896
  opt.target = effectiveTarget;
12886
12897
  pendingGroupPromotionRef.current = null;
12898
+ pendingGroupDrillInRef.current = { groupId: drillGroup.id, childId: effectiveTargetId, target: effectiveTarget };
12899
+ selectElements([effectiveTargetId], false, false);
12900
+ fabricCanvas.requestRenderAll();
12887
12901
  }
12888
12902
  } else if (!target || targetId === "__background__") {
12889
12903
  const isMultiSelectKey = !!(((_k = opt.e) == null ? void 0 : _k.shiftKey) || ((_l = opt.e) == null ? void 0 : _l.metaKey) || ((_m = opt.e) == null ? void 0 : _m.ctrlKey));
@@ -12910,6 +12924,7 @@ const PageCanvas = react.forwardRef(
12910
12924
  fabricCanvas._target = selection;
12911
12925
  opt.target = selection;
12912
12926
  pendingGroupPromotionRef.current = { groupId: parent.id, selection };
12927
+ pendingGroupDrillInRef.current = null;
12913
12928
  } else if (memberObjs.length === 1) {
12914
12929
  const only = memberObjs[0];
12915
12930
  only.__pixldocsGroupSelection = parent.id;
@@ -12917,6 +12932,7 @@ const PageCanvas = react.forwardRef(
12917
12932
  fabricCanvas._target = only;
12918
12933
  opt.target = only;
12919
12934
  pendingGroupPromotionRef.current = { groupId: parent.id, selection: only };
12935
+ pendingGroupDrillInRef.current = null;
12920
12936
  }
12921
12937
  }
12922
12938
  }
@@ -13026,7 +13042,7 @@ const PageCanvas = react.forwardRef(
13026
13042
  o.__lockScaleDuringCrop = false;
13027
13043
  });
13028
13044
  fabricCanvas.on("mouse:up", (e) => {
13029
- var _a2;
13045
+ var _a2, _b2, _c;
13030
13046
  clearTransforming();
13031
13047
  setGuides([]);
13032
13048
  setRotationLabel(null);
@@ -13034,6 +13050,29 @@ const PageCanvas = react.forwardRef(
13034
13050
  objectResizeActiveSnapRef.current = null;
13035
13051
  groupResizeActiveSnapRef.current = null;
13036
13052
  dragStarted = false;
13053
+ const pendingDrillIn = pendingGroupDrillInRef.current;
13054
+ pendingGroupDrillInRef.current = null;
13055
+ if (pendingDrillIn && !didTransformRef.current) {
13056
+ const activeNow = fabricCanvas.getActiveObject();
13057
+ if (activeNow !== pendingDrillIn.target) {
13058
+ isSyncingSelectionToFabricRef.current = true;
13059
+ try {
13060
+ restoreSuppressedGroupBorders();
13061
+ fabricCanvas.__activeEditingGroupId = pendingDrillIn.groupId;
13062
+ delete pendingDrillIn.target.__pixldocsGroupSelection;
13063
+ delete pendingDrillIn.target.__pixldocsLogicalGroupIds;
13064
+ (_b2 = (_a2 = pendingDrillIn.target).set) == null ? void 0 : _b2.call(_a2, { selectable: true, evented: true, hasBorders: true, hasControls: true });
13065
+ fabricCanvas.setActiveObject(pendingDrillIn.target);
13066
+ pendingDrillIn.target.setCoords();
13067
+ fabricCanvas.requestRenderAll();
13068
+ } finally {
13069
+ requestAnimationFrame(() => {
13070
+ isSyncingSelectionToFabricRef.current = false;
13071
+ });
13072
+ }
13073
+ selectElements([pendingDrillIn.childId], false, false);
13074
+ }
13075
+ }
13037
13076
  const pendingPromotion = pendingGroupPromotionRef.current;
13038
13077
  pendingGroupPromotionRef.current = null;
13039
13078
  if (pendingPromotion && !didTransformRef.current) {
@@ -13067,7 +13106,7 @@ const PageCanvas = react.forwardRef(
13067
13106
  }
13068
13107
  }
13069
13108
  const activeObj = fabricCanvas.getActiveObject();
13070
- if (activeObj && (activeObj.__cropGroup || ((_a2 = activeObj._ct) == null ? void 0 : _a2.isCropGroup))) {
13109
+ if (activeObj && (activeObj.__cropGroup || ((_c = activeObj._ct) == null ? void 0 : _c.isCropGroup))) {
13071
13110
  activeObj.__lockScaleDuringCrop = false;
13072
13111
  if (activeObj.__cropDrag) {
13073
13112
  delete activeObj.__cropDrag;
@@ -23271,9 +23310,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23271
23310
  }
23272
23311
  return svgString;
23273
23312
  }
23274
- const resolvedPackageVersion = "0.5.243";
23313
+ const resolvedPackageVersion = "0.5.244";
23275
23314
  const PACKAGE_VERSION = resolvedPackageVersion;
23276
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.243";
23315
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.244";
23277
23316
  const roundParityValue = (value) => {
23278
23317
  if (typeof value !== "number") return value;
23279
23318
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24087,7 +24126,7 @@ class PixldocsRenderer {
24087
24126
  await this.waitForCanvasScene(container, cloned, i);
24088
24127
  }
24089
24128
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24090
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-V2qBQ4Xs.cjs"));
24129
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BUlPzdRT.cjs"));
24091
24130
  const prepared = preparePagesForExport(
24092
24131
  cloned.pages,
24093
24132
  canvasWidth,
@@ -26407,7 +26446,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26407
26446
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26408
26447
  sanitizeSvgTreeForPdf(svgToDraw);
26409
26448
  try {
26410
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-V2qBQ4Xs.cjs"));
26449
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BUlPzdRT.cjs"));
26411
26450
  try {
26412
26451
  await logTextMeasurementDiagnostic(svgToDraw);
26413
26452
  } catch {
@@ -26804,4 +26843,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
26804
26843
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
26805
26844
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
26806
26845
  exports.warmTemplateFromForm = warmTemplateFromForm;
26807
- //# sourceMappingURL=index-UuNicsNZ.cjs.map
26846
+ //# sourceMappingURL=index-Bu8x_hs7.cjs.map