@pixldocs/canvas-renderer 0.5.242 → 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.
@@ -11176,6 +11176,7 @@ const PageCanvas = forwardRef(
11176
11176
  const preserveEditingScopeOnSelectionClearRef = useRef(false);
11177
11177
  const preserveActiveSelectionAfterTransformRef = useRef(null);
11178
11178
  const pendingGroupPromotionRef = useRef(null);
11179
+ const pendingGroupDrillInRef = useRef(null);
11179
11180
  const imageReloadRequestSeqRef = useRef(/* @__PURE__ */ new Map());
11180
11181
  useRef(null);
11181
11182
  const groupBoundsResizingRef = useRef(false);
@@ -12246,7 +12247,7 @@ const PageCanvas = forwardRef(
12246
12247
  const active = fabricCanvas.getActiveObject();
12247
12248
  let hitChild = null;
12248
12249
  if (active instanceof fabric.ActiveSelection) {
12249
- const pointer = fabricCanvas.getViewportPoint(opt.e);
12250
+ const pointer = fabricCanvas.getPointer(opt.e);
12250
12251
  const objs = active.getObjects();
12251
12252
  for (let i = objs.length - 1; i >= 0; i--) {
12252
12253
  const o = objs[i];
@@ -12467,10 +12468,36 @@ const PageCanvas = forwardRef(
12467
12468
  }
12468
12469
  };
12469
12470
  const isMultiSelectModifier = (event) => !!((event == null ? void 0 : event.shiftKey) || (event == null ? void 0 : event.metaKey) || (event == null ? void 0 : event.ctrlKey));
12471
+ const pickChildInActiveSelectionAtPointer = (selection, event) => {
12472
+ var _a2, _b2, _c, _d, _e;
12473
+ try {
12474
+ const pointer = fabricCanvas.getPointer(event);
12475
+ const viewportPointer = (_a2 = fabricCanvas.getViewportPoint) == null ? void 0 : _a2.call(fabricCanvas, event);
12476
+ const zoom3 = ((_b2 = fabricCanvas.getZoom) == null ? void 0 : _b2.call(fabricCanvas)) || 1;
12477
+ const tolerance = Math.max(3, 6 / zoom3);
12478
+ const members = selection.getObjects();
12479
+ for (let i = members.length - 1; i >= 0; i--) {
12480
+ const obj = members[i];
12481
+ const id = getObjectId(obj);
12482
+ if (!id || id === "__background__" || obj.visible === false) continue;
12483
+ (_c = obj.setCoords) == null ? void 0 : _c.call(obj);
12484
+ const containsScene = typeof obj.containsPoint === "function" && obj.containsPoint(pointer);
12485
+ const containsViewport = !!(viewportPointer && typeof obj.containsPoint === "function" && obj.containsPoint(viewportPointer));
12486
+ if (containsScene || containsViewport) return obj;
12487
+ const br = ((_d = obj.getBoundingRect) == null ? void 0 : _d.call(obj, true, true)) ?? ((_e = obj.getBoundingRect) == null ? void 0 : _e.call(obj));
12488
+ 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) {
12489
+ return obj;
12490
+ }
12491
+ }
12492
+ } catch {
12493
+ return null;
12494
+ }
12495
+ return null;
12496
+ };
12470
12497
  const pickSelectableObjectAtPointer = (event) => {
12471
12498
  var _a2;
12472
12499
  try {
12473
- const pointer = fabricCanvas.getViewportPoint(event);
12500
+ const pointer = fabricCanvas.getPointer(event);
12474
12501
  const objects = fabricCanvas.getObjects();
12475
12502
  for (let i = objects.length - 1; i >= 0; i--) {
12476
12503
  const obj = objects[i];
@@ -12734,8 +12761,16 @@ const PageCanvas = forwardRef(
12734
12761
  syncLockedRef.current = true;
12735
12762
  lockEdits();
12736
12763
  }
12737
- const target = opt.target;
12738
- const targetId = target ? getObjectId(target) : null;
12764
+ let target = opt.target;
12765
+ let targetId = target ? getObjectId(target) : null;
12766
+ if (target instanceof fabric.ActiveSelection && target.__pixldocsGroupSelection && target === fabricCanvas.getActiveObject()) {
12767
+ const child = pickChildInActiveSelectionAtPointer(target, opt.e);
12768
+ const childId = child ? getObjectId(child) : null;
12769
+ if (child && childId) {
12770
+ target = child;
12771
+ targetId = childId;
12772
+ }
12773
+ }
12739
12774
  const activeEditingGroupId = fabricCanvas.__activeEditingGroupId ?? null;
12740
12775
  const pageNow = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId);
12741
12776
  const childrenNow = (pageNow == null ? void 0 : pageNow.children) ?? [];
@@ -12752,6 +12787,7 @@ const PageCanvas = forwardRef(
12752
12787
  activeObjects: fabricCanvas.getActiveObjects().slice()
12753
12788
  };
12754
12789
  pendingGroupPromotionRef.current = null;
12790
+ pendingGroupDrillInRef.current = null;
12755
12791
  return;
12756
12792
  }
12757
12793
  }
@@ -12774,28 +12810,21 @@ const PageCanvas = forwardRef(
12774
12810
  const activeNowEarly = fabricCanvas.getActiveObject();
12775
12811
  const asGroupId = target instanceof fabric.ActiveSelection ? target.__pixldocsGroupSelection : void 0;
12776
12812
  if (target instanceof fabric.ActiveSelection && asGroupId && target === activeNowEarly) {
12777
- try {
12778
- const pointer = fabricCanvas.getViewportPoint(opt.e);
12779
- const members = target.getObjects();
12780
- for (let i = members.length - 1; i >= 0; i--) {
12781
- const m = members[i];
12782
- if (m.visible === false) continue;
12783
- if (typeof m.containsPoint === "function" && m.containsPoint(pointer)) {
12784
- const mid = getObjectId(m);
12785
- if (mid) {
12786
- effectiveTarget = m;
12787
- effectiveTargetId = mid;
12788
- }
12789
- break;
12790
- }
12791
- }
12792
- } catch {
12813
+ const child = pickChildInActiveSelectionAtPointer(target, opt.e);
12814
+ const childId = child ? getObjectId(child) : null;
12815
+ if (child && childId) {
12816
+ effectiveTarget = child;
12817
+ effectiveTargetId = childId;
12793
12818
  }
12794
12819
  }
12795
12820
  const parent = findTopmostPromotableGroup(effectiveTargetId);
12796
12821
  const targetIsInCrop = !!(effectiveTarget instanceof fabric.Group && isCropGroupInCropMode(effectiveTarget) || (effectiveTarget == null ? void 0 : effectiveTarget.group) instanceof fabric.Group && isCropGroupInCropMode(effectiveTarget.group));
12797
12822
  const activeNow = fabricCanvas.getActiveObject();
12798
- const alreadyThisGroup = activeNow instanceof fabric.ActiveSelection && activeNow.__pixldocsGroupSelection === (parent == null ? void 0 : parent.id);
12823
+ const activeGroupSelectionId = activeNow instanceof fabric.ActiveSelection ? activeNow.__pixldocsGroupSelection : void 0;
12824
+ const activeGroupNode = activeGroupSelectionId ? findNodeById(childrenNow, activeGroupSelectionId) : null;
12825
+ const activeGroupContainsTarget = !!(activeGroupNode && isGroup(activeGroupNode) && getAllElementIds(activeGroupNode.children ?? []).includes(effectiveTargetId));
12826
+ const alreadyThisGroup = !!(activeGroupSelectionId && activeGroupContainsTarget);
12827
+ const drillGroup = alreadyThisGroup && activeGroupNode && isGroup(activeGroupNode) ? activeGroupNode : parent;
12799
12828
  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));
12800
12829
  const isDeepSelectKey = !!((_i = opt.e) == null ? void 0 : _i.altKey);
12801
12830
  if (isDeepSelectKey) {
@@ -12825,7 +12854,8 @@ const PageCanvas = forwardRef(
12825
12854
  opt.target = only;
12826
12855
  pendingGroupPromotionRef.current = { groupId: parent.id, selection: only };
12827
12856
  }
12828
- } else if (parent && !parent.backgroundColor && !targetIsInCrop && alreadyThisGroup && !isMultiSelectKey && effectiveTarget !== activeNow) {
12857
+ pendingGroupDrillInRef.current = null;
12858
+ } else if (drillGroup && !drillGroup.backgroundColor && !targetIsInCrop && alreadyThisGroup && !isMultiSelectKey && effectiveTarget !== activeNow) {
12829
12859
  try {
12830
12860
  skipSelectionClearOnDiscardRef.current = true;
12831
12861
  preserveEditingScopeOnSelectionClearRef.current = true;
@@ -12835,7 +12865,7 @@ const PageCanvas = forwardRef(
12835
12865
  skipSelectionClearOnDiscardRef.current = false;
12836
12866
  preserveEditingScopeOnSelectionClearRef.current = false;
12837
12867
  }
12838
- fabricCanvas.__activeEditingGroupId = parent.id;
12868
+ fabricCanvas.__activeEditingGroupId = drillGroup.id;
12839
12869
  delete effectiveTarget.__pixldocsGroupSelection;
12840
12870
  delete effectiveTarget.__pixldocsLogicalGroupIds;
12841
12871
  try {
@@ -12847,6 +12877,9 @@ const PageCanvas = forwardRef(
12847
12877
  fabricCanvas._target = effectiveTarget;
12848
12878
  opt.target = effectiveTarget;
12849
12879
  pendingGroupPromotionRef.current = null;
12880
+ pendingGroupDrillInRef.current = { groupId: drillGroup.id, childId: effectiveTargetId, target: effectiveTarget };
12881
+ selectElements([effectiveTargetId], false, false);
12882
+ fabricCanvas.requestRenderAll();
12850
12883
  }
12851
12884
  } else if (!target || targetId === "__background__") {
12852
12885
  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));
@@ -12873,6 +12906,7 @@ const PageCanvas = forwardRef(
12873
12906
  fabricCanvas._target = selection;
12874
12907
  opt.target = selection;
12875
12908
  pendingGroupPromotionRef.current = { groupId: parent.id, selection };
12909
+ pendingGroupDrillInRef.current = null;
12876
12910
  } else if (memberObjs.length === 1) {
12877
12911
  const only = memberObjs[0];
12878
12912
  only.__pixldocsGroupSelection = parent.id;
@@ -12880,6 +12914,7 @@ const PageCanvas = forwardRef(
12880
12914
  fabricCanvas._target = only;
12881
12915
  opt.target = only;
12882
12916
  pendingGroupPromotionRef.current = { groupId: parent.id, selection: only };
12917
+ pendingGroupDrillInRef.current = null;
12883
12918
  }
12884
12919
  }
12885
12920
  }
@@ -12989,7 +13024,7 @@ const PageCanvas = forwardRef(
12989
13024
  o.__lockScaleDuringCrop = false;
12990
13025
  });
12991
13026
  fabricCanvas.on("mouse:up", (e) => {
12992
- var _a2;
13027
+ var _a2, _b2, _c;
12993
13028
  clearTransforming();
12994
13029
  setGuides([]);
12995
13030
  setRotationLabel(null);
@@ -12997,6 +13032,29 @@ const PageCanvas = forwardRef(
12997
13032
  objectResizeActiveSnapRef.current = null;
12998
13033
  groupResizeActiveSnapRef.current = null;
12999
13034
  dragStarted = false;
13035
+ const pendingDrillIn = pendingGroupDrillInRef.current;
13036
+ pendingGroupDrillInRef.current = null;
13037
+ if (pendingDrillIn && !didTransformRef.current) {
13038
+ const activeNow = fabricCanvas.getActiveObject();
13039
+ if (activeNow !== pendingDrillIn.target) {
13040
+ isSyncingSelectionToFabricRef.current = true;
13041
+ try {
13042
+ restoreSuppressedGroupBorders();
13043
+ fabricCanvas.__activeEditingGroupId = pendingDrillIn.groupId;
13044
+ delete pendingDrillIn.target.__pixldocsGroupSelection;
13045
+ delete pendingDrillIn.target.__pixldocsLogicalGroupIds;
13046
+ (_b2 = (_a2 = pendingDrillIn.target).set) == null ? void 0 : _b2.call(_a2, { selectable: true, evented: true, hasBorders: true, hasControls: true });
13047
+ fabricCanvas.setActiveObject(pendingDrillIn.target);
13048
+ pendingDrillIn.target.setCoords();
13049
+ fabricCanvas.requestRenderAll();
13050
+ } finally {
13051
+ requestAnimationFrame(() => {
13052
+ isSyncingSelectionToFabricRef.current = false;
13053
+ });
13054
+ }
13055
+ selectElements([pendingDrillIn.childId], false, false);
13056
+ }
13057
+ }
13000
13058
  const pendingPromotion = pendingGroupPromotionRef.current;
13001
13059
  pendingGroupPromotionRef.current = null;
13002
13060
  if (pendingPromotion && !didTransformRef.current) {
@@ -13030,7 +13088,7 @@ const PageCanvas = forwardRef(
13030
13088
  }
13031
13089
  }
13032
13090
  const activeObj = fabricCanvas.getActiveObject();
13033
- if (activeObj && (activeObj.__cropGroup || ((_a2 = activeObj._ct) == null ? void 0 : _a2.isCropGroup))) {
13091
+ if (activeObj && (activeObj.__cropGroup || ((_c = activeObj._ct) == null ? void 0 : _c.isCropGroup))) {
13034
13092
  activeObj.__lockScaleDuringCrop = false;
13035
13093
  if (activeObj.__cropDrag) {
13036
13094
  delete activeObj.__cropDrag;
@@ -23234,9 +23292,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23234
23292
  }
23235
23293
  return svgString;
23236
23294
  }
23237
- const resolvedPackageVersion = "0.5.242";
23295
+ const resolvedPackageVersion = "0.5.244";
23238
23296
  const PACKAGE_VERSION = resolvedPackageVersion;
23239
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.242";
23297
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.244";
23240
23298
  const roundParityValue = (value) => {
23241
23299
  if (typeof value !== "number") return value;
23242
23300
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24050,7 +24108,7 @@ class PixldocsRenderer {
24050
24108
  await this.waitForCanvasScene(container, cloned, i);
24051
24109
  }
24052
24110
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24053
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-CsrQStE8.js");
24111
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-BWQ8fyXp.js");
24054
24112
  const prepared = preparePagesForExport(
24055
24113
  cloned.pages,
24056
24114
  canvasWidth,
@@ -26370,7 +26428,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26370
26428
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26371
26429
  sanitizeSvgTreeForPdf(svgToDraw);
26372
26430
  try {
26373
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-CsrQStE8.js");
26431
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-BWQ8fyXp.js");
26374
26432
  try {
26375
26433
  await logTextMeasurementDiagnostic(svgToDraw);
26376
26434
  } catch {
@@ -26770,4 +26828,4 @@ export {
26770
26828
  buildTeaserBlurFlatKeys as y,
26771
26829
  collectFontDescriptorsFromConfig as z
26772
26830
  };
26773
- //# sourceMappingURL=index-BQ5V2uT8.js.map
26831
+ //# sourceMappingURL=index-xJBNIfjT.js.map