@pixldocs/canvas-renderer 0.5.285 → 0.5.287

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.
@@ -11230,6 +11230,26 @@ const PageCanvas = forwardRef(
11230
11230
  hoveredGroupId
11231
11231
  } = useEditorStore();
11232
11232
  const storeSelectedIds = canvas.selectedIds ?? [];
11233
+ const restoreGroupSelectionSnapshot = useCallback((snapshot) => {
11234
+ const fc = fabricRef.current;
11235
+ const groupId = snapshot == null ? void 0 : snapshot.groupSelectionId;
11236
+ if (!fc || !groupId || snapshot.memberIds.length < 2 || editingTextIdRef.current) return;
11237
+ const members = snapshot.memberIds.map((id) => fc.getObjects().find((o) => getObjectId(o) === id)).filter((o) => !!o);
11238
+ if (members.length < 2) return;
11239
+ isSyncingSelectionToFabricRef.current = true;
11240
+ try {
11241
+ const active = fc.getActiveObject();
11242
+ const selection = active instanceof fabric.ActiveSelection && members.every((member) => active.getObjects().includes(member)) ? active : new fabric.ActiveSelection(members, { canvas: fc });
11243
+ applyLogicalGroupSelectionVisualState(selection, groupId);
11244
+ fc.setActiveObject(selection);
11245
+ selection.setCoords();
11246
+ fc.requestRenderAll();
11247
+ } finally {
11248
+ requestAnimationFrame(() => {
11249
+ isSyncingSelectionToFabricRef.current = false;
11250
+ });
11251
+ }
11252
+ }, [applyLogicalGroupSelectionVisualState]);
11233
11253
  const currentPage = useMemo(() => (canvas.pages ?? []).find((p) => p.id === pageId), [canvas.pages, pageId]);
11234
11254
  useMemo(() => {
11235
11255
  const ids = storeSelectedIds ?? [];
@@ -12684,32 +12704,11 @@ const PageCanvas = forwardRef(
12684
12704
  const restorePreservedGroupSelectionSoon = (snapshot = preserveActiveSelectionAfterTransformRef.current) => {
12685
12705
  if (!(snapshot == null ? void 0 : snapshot.groupSelectionId) || snapshot.memberIds.length < 2) return;
12686
12706
  const groupId = snapshot.groupSelectionId;
12687
- const memberIds = [...snapshot.memberIds];
12688
12707
  selectElements([groupId], false, false);
12689
12708
  requestAnimationFrame(() => {
12690
12709
  setTimeout(() => {
12691
- const fc = fabricRef.current;
12692
- if (!fc || !isActiveRef.current || editingTextIdRef.current) return;
12693
- const active = fc.getActiveObject();
12694
- if (active instanceof fabric.ActiveSelection && active.__pixldocsGroupSelection === groupId) {
12695
- restoreGroupSelectionVisualState(active, groupId);
12696
- fc.requestRenderAll();
12697
- return;
12698
- }
12699
- const members = memberIds.map((id) => fc.getObjects().find((o) => getObjectId(o) === id)).filter((o) => !!o);
12700
- if (members.length < 2) return;
12701
- isSyncingSelectionToFabricRef.current = true;
12702
- try {
12703
- const selection = new fabric.ActiveSelection(members, { canvas: fc });
12704
- restoreGroupSelectionVisualState(selection, groupId);
12705
- fc.setActiveObject(selection);
12706
- selection.setCoords();
12707
- fc.requestRenderAll();
12708
- } finally {
12709
- requestAnimationFrame(() => {
12710
- isSyncingSelectionToFabricRef.current = false;
12711
- });
12712
- }
12710
+ if (!isActiveRef.current) return;
12711
+ restoreGroupSelectionSnapshot(snapshot);
12713
12712
  }, 0);
12714
12713
  });
12715
12714
  };
@@ -13179,7 +13178,8 @@ const PageCanvas = forwardRef(
13179
13178
  if (memberIds.length > 1) {
13180
13179
  restorePreservedGroupSelectionSoon({
13181
13180
  memberIds,
13182
- groupSelectionId: pendingDrillIn.groupId
13181
+ groupSelectionId: pendingDrillIn.groupId,
13182
+ expiresAt: Date.now() + 1200
13183
13183
  });
13184
13184
  } else {
13185
13185
  selectElements([pendingDrillIn.groupId], false, false);
@@ -14596,10 +14596,13 @@ const PageCanvas = forwardRef(
14596
14596
  }
14597
14597
  skipSelectionClearOnDiscardRef.current = false;
14598
14598
  if (wasGroupSel) {
14599
- restorePreservedGroupSelectionSoon({
14599
+ const resizeRestoreSnapshot = {
14600
14600
  memberIds: membersToReselect.map((obj) => getObjectId(obj)).filter((id) => !!id && id !== "__background__"),
14601
- groupSelectionId: wasGroupSel
14602
- });
14601
+ groupSelectionId: wasGroupSel,
14602
+ expiresAt: Date.now() + 1200
14603
+ };
14604
+ recentGroupSelectionRestoreRef.current = resizeRestoreSnapshot;
14605
+ restorePreservedGroupSelectionSoon(resizeRestoreSnapshot);
14603
14606
  }
14604
14607
  fabricCanvas.requestRenderAll();
14605
14608
  }
@@ -15689,6 +15692,10 @@ const PageCanvas = forwardRef(
15689
15692
  }
15690
15693
  }
15691
15694
  }
15695
+ const recentGroupRestore = recentGroupSelectionRestoreRef.current;
15696
+ if ((recentGroupRestore == null ? void 0 : recentGroupRestore.groupSelectionId) && recentGroupRestore.expiresAt > Date.now()) {
15697
+ restoreGroupSelectionSnapshot(recentGroupRestore);
15698
+ }
15692
15699
  preserveSelectionAfterTransformIdRef.current = null;
15693
15700
  preserveActiveSelectionAfterTransformRef.current = null;
15694
15701
  syncTriggeredByPanelRef.current = false;
@@ -23612,9 +23619,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23612
23619
  }
23613
23620
  return svgString;
23614
23621
  }
23615
- const resolvedPackageVersion = "0.5.285";
23622
+ const resolvedPackageVersion = "0.5.287";
23616
23623
  const PACKAGE_VERSION = resolvedPackageVersion;
23617
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.285";
23624
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.287";
23618
23625
  const roundParityValue = (value) => {
23619
23626
  if (typeof value !== "number") return value;
23620
23627
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24428,7 +24435,7 @@ class PixldocsRenderer {
24428
24435
  await this.waitForCanvasScene(container, cloned, i);
24429
24436
  }
24430
24437
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24431
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-B0C--0iz.js");
24438
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Cdzd1M4c.js");
24432
24439
  const prepared = preparePagesForExport(
24433
24440
  cloned.pages,
24434
24441
  canvasWidth,
@@ -26748,7 +26755,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26748
26755
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26749
26756
  sanitizeSvgTreeForPdf(svgToDraw);
26750
26757
  try {
26751
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-B0C--0iz.js");
26758
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Cdzd1M4c.js");
26752
26759
  try {
26753
26760
  await logTextMeasurementDiagnostic(svgToDraw);
26754
26761
  } catch {
@@ -27148,4 +27155,4 @@ export {
27148
27155
  buildTeaserBlurFlatKeys as y,
27149
27156
  collectFontDescriptorsFromConfig as z
27150
27157
  };
27151
- //# sourceMappingURL=index-3k0uE4wB.js.map
27158
+ //# sourceMappingURL=index-SOarDnbw.js.map