@pixldocs/canvas-renderer 0.5.402 → 0.5.404

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.
@@ -11520,8 +11520,8 @@ function applyWarpAwareSelectionBorders(selection) {
11520
11520
  let targetAngle = null;
11521
11521
  const isLogicalGroupSelection = !!selection.__pixldocsGroupSelection;
11522
11522
  const frozenGroupAngle = selection.__pixldocsFrozenGroupAngle;
11523
- if (isLogicalGroupSelection && typeof frozenGroupAngle === "number" && Math.abs(frozenGroupAngle) > 0.5) {
11524
- targetAngle = frozenGroupAngle;
11523
+ if (isLogicalGroupSelection) {
11524
+ targetAngle = typeof frozenGroupAngle === "number" ? frozenGroupAngle : 0;
11525
11525
  }
11526
11526
  if (targetAngle == null && dominant && Math.abs(dominant.angle) > 0.5 && // Canva-style: a *logical group* bbox is authoritative from the
11527
11527
  // persisted group.angle only. Individual child rotations must not
@@ -13255,7 +13255,7 @@ const PageCanvas = react.forwardRef(
13255
13255
  transformingIdsRef.current.clear();
13256
13256
  };
13257
13257
  const prepareGroupSelectionTransformStart = (target) => {
13258
- var _a2, _b2;
13258
+ var _a2, _b2, _c2;
13259
13259
  const active = target instanceof fabric__namespace.ActiveSelection ? target : fabricCanvas.getActiveObject();
13260
13260
  if (!(active instanceof fabric__namespace.ActiveSelection)) return;
13261
13261
  if (!activeSelectionMoveStartRef.current || activeSelectionMoveStartRef.current.selection !== active) {
@@ -13274,6 +13274,8 @@ const PageCanvas = react.forwardRef(
13274
13274
  if (!groupNode) return;
13275
13275
  const groupAbs = getAbsoluteBounds(groupNode, pageChildren2);
13276
13276
  const rect = active.getBoundingRect();
13277
+ const currentTransform = fabricCanvas._currentTransform;
13278
+ const originalSelectionAngle = (currentTransform == null ? void 0 : currentTransform.target) === active && typeof ((_c2 = currentTransform == null ? void 0 : currentTransform.original) == null ? void 0 : _c2.angle) === "number" ? currentTransform.original.angle : active.angle ?? 0;
13277
13279
  groupSelectionTransformStartRef.current = {
13278
13280
  groupId,
13279
13281
  selection: active,
@@ -13281,7 +13283,8 @@ const PageCanvas = react.forwardRef(
13281
13283
  selectionTop: rect.top,
13282
13284
  groupLeft: groupAbs.left,
13283
13285
  groupTop: groupAbs.top,
13284
- selectionAngle: ((active.angle ?? 0) % 360 + 360) % 360
13286
+ selectionAngle: (originalSelectionAngle % 360 + 360) % 360,
13287
+ groupAngle: isGroup(groupNode) ? groupNode.angle ?? 0 : 0
13285
13288
  };
13286
13289
  logRotDriftSelectionSnapshot("transform-start", active, {
13287
13290
  time: Math.round(performance.now()),
@@ -13714,6 +13717,7 @@ const PageCanvas = react.forwardRef(
13714
13717
  fabricCanvas.__isUserTransforming = true;
13715
13718
  syncLockedRef.current = true;
13716
13719
  lockEdits();
13720
+ prepareGroupSelectionTransformStart(opt.target ?? null);
13717
13721
  }
13718
13722
  let target = opt.target;
13719
13723
  let targetId = target ? getObjectId(target) : null;
@@ -14405,6 +14409,14 @@ const PageCanvas = react.forwardRef(
14405
14409
  const asRect0 = obj.getBoundingRect();
14406
14410
  let didReflowTextChild = false;
14407
14411
  for (const child of obj.getObjects()) {
14412
+ const childLocalAngle = child.__asLiveOrigAngle != null ? child.__asLiveOrigAngle : child.angle ?? 0;
14413
+ const isRotatedChild = Math.abs((childLocalAngle % 360 + 360) % 360) > 0.5 && Math.abs((childLocalAngle % 360 + 360) % 360 - 360) > 0.5;
14414
+ if (isRotatedChild) {
14415
+ if (child.__asLiveOrigAngle == null) {
14416
+ child.__asLiveOrigAngle = child.angle ?? 0;
14417
+ }
14418
+ continue;
14419
+ }
14408
14420
  if (child instanceof fabric__namespace.Group && (child.__cropGroup || ((_f = child._ct) == null ? void 0 : _f.isCropGroup))) {
14409
14421
  const ct = child.__cropData;
14410
14422
  if (!ct) continue;
@@ -14827,6 +14839,7 @@ const PageCanvas = react.forwardRef(
14827
14839
  markSimpleTransform(e);
14828
14840
  didTransformRef.current = true;
14829
14841
  const tr = e.target;
14842
+ prepareGroupSelectionTransformStart(tr);
14830
14843
  if (shouldLogRotDriftLiveTick(tr, "rotating")) {
14831
14844
  logRotDriftSelectionSnapshot("rotating", tr, {
14832
14845
  time: Math.round(performance.now()),
@@ -14939,7 +14952,7 @@ const PageCanvas = react.forwardRef(
14939
14952
  });
14940
14953
  let cropGroupSaveTimer = null;
14941
14954
  fabricCanvas.on("object:modified", (e) => {
14942
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j;
14955
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k;
14943
14956
  try {
14944
14957
  if (suppressObjectModifiedDuringInternalReselectRef.current) return;
14945
14958
  dragStarted = false;
@@ -14965,13 +14978,16 @@ const PageCanvas = react.forwardRef(
14965
14978
  const t = e.target;
14966
14979
  if (t instanceof fabric__namespace.ActiveSelection) {
14967
14980
  const gid = t.__pixldocsGroupSelection;
14968
- const delta = ((t.angle ?? 0) + 360) % 360;
14981
+ const transformStart = gid && ((_a2 = groupSelectionTransformStartRef.current) == null ? void 0 : _a2.groupId) === gid && groupSelectionTransformStartRef.current.selection === t ? groupSelectionTransformStartRef.current : null;
14982
+ const current = ((t.angle ?? 0) % 360 + 360) % 360;
14983
+ const start = (((transformStart == null ? void 0 : transformStart.selectionAngle) ?? (transformStart == null ? void 0 : transformStart.groupAngle) ?? 0) % 360 + 360) % 360;
14984
+ const delta = ((current - start) % 360 + 360) % 360;
14969
14985
  const deltaSigned = delta > 180 ? delta - 360 : delta;
14970
14986
  if (gid && Math.abs(deltaSigned) > 0.01) {
14971
14987
  const pageNow = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId);
14972
14988
  const node = pageNow ? findNodeById(pageNow.children ?? [], gid) : null;
14973
14989
  if (node && isGroup(node)) {
14974
- const prev = node.angle ?? 0;
14990
+ const prev = (transformStart == null ? void 0 : transformStart.groupAngle) ?? (node.angle ?? 0);
14975
14991
  const next = ((prev + deltaSigned) % 360 + 360) % 360;
14976
14992
  const nextSigned = next > 180 ? next - 360 : next;
14977
14993
  useEditorStore.getState().updateNode(
@@ -15010,7 +15026,7 @@ const PageCanvas = react.forwardRef(
15010
15026
  const active = fabricCanvas.getActiveObject();
15011
15027
  const activeId = active ? getObjectId(active) : null;
15012
15028
  if (active && activeId && activeId !== "__background__" && !(active instanceof fabric__namespace.Group)) {
15013
- const pageChildrenForParent = ((_a2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _a2.children) ?? [];
15029
+ const pageChildrenForParent = ((_b2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
15014
15030
  const parentGroup = findParentGroup(pageChildrenForParent, activeId);
15015
15031
  if (parentGroup && isGroup(parentGroup) && parentGroup.backgroundColor) {
15016
15032
  let fabricSectionGroup = active.group && active.group instanceof fabric__namespace.Group ? active.group : null;
@@ -15092,7 +15108,7 @@ const PageCanvas = react.forwardRef(
15092
15108
  useEditorStore.getState().reflowStackGroupInPage(pageId, groupId);
15093
15109
  }
15094
15110
  const stateAfter = useEditorStore.getState();
15095
- const pageAfter = ((_b2 = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _b2.children) ?? [];
15111
+ const pageAfter = ((_c2 = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c2.children) ?? [];
15096
15112
  const groupNodeAfter = findNodeById(pageAfter, groupId);
15097
15113
  if (groupNodeAfter) {
15098
15114
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -15154,7 +15170,7 @@ const PageCanvas = react.forwardRef(
15154
15170
  }
15155
15171
  if (active && active instanceof fabric__namespace.Group && active.__docuforgeSectionGroup && getObjectId(active)) {
15156
15172
  const groupId = getObjectId(active);
15157
- const pageChildrenSec = ((_c2 = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _c2.children) ?? [];
15173
+ const pageChildrenSec = ((_d = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
15158
15174
  const modifiedTarget2 = e == null ? void 0 : e.target;
15159
15175
  const resizeScaleTarget = lastResizeScaleTargetRef.current;
15160
15176
  lastResizeScaleTargetRef.current = null;
@@ -15185,7 +15201,7 @@ const PageCanvas = react.forwardRef(
15185
15201
  const node = findNodeById(pageChildrenSec, groupId);
15186
15202
  if (isChildModified && node && !groupMoved) {
15187
15203
  const stateAfter = useEditorStore.getState();
15188
- const pageAfter = ((_d = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _d.children) ?? [];
15204
+ const pageAfter = ((_e = stateAfter.canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
15189
15205
  const groupNodeAfter = findNodeById(pageAfter, groupId);
15190
15206
  if (groupNodeAfter) {
15191
15207
  const abs = getAbsoluteBounds(groupNodeAfter, pageAfter);
@@ -15201,7 +15217,7 @@ const PageCanvas = react.forwardRef(
15201
15217
  }
15202
15218
  if (active && active instanceof fabric__namespace.Group && !(active instanceof fabric__namespace.ActiveSelection) && getObjectId(active)) {
15203
15219
  const groupId = getObjectId(active);
15204
- const pageChildren3 = ((_e = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _e.children) ?? [];
15220
+ const pageChildren3 = ((_f = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _f.children) ?? [];
15205
15221
  const w = (active.width ?? 0) * (active.scaleX ?? 1);
15206
15222
  const h = (active.height ?? 0) * (active.scaleY ?? 1);
15207
15223
  const centerX = active.left ?? 0;
@@ -15223,7 +15239,7 @@ const PageCanvas = react.forwardRef(
15223
15239
  }
15224
15240
  const activeObj = fabricCanvas.getActiveObject();
15225
15241
  let activeObjects = fabricCanvas.getActiveObjects();
15226
- const activeSelectionMoveStart = activeObj instanceof fabric__namespace.ActiveSelection && ((_f = activeSelectionMoveStartRef.current) == null ? void 0 : _f.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
15242
+ const activeSelectionMoveStart = activeObj instanceof fabric__namespace.ActiveSelection && ((_g = activeSelectionMoveStartRef.current) == null ? void 0 : _g.selection) === activeObj ? activeSelectionMoveStartRef.current : null;
15227
15243
  const activeSelectionDelta = activeObj instanceof fabric__namespace.ActiveSelection && activeSelectionMoveStart ? (() => {
15228
15244
  const rect = activeObj.getBoundingRect();
15229
15245
  return {
@@ -15615,7 +15631,7 @@ const PageCanvas = react.forwardRef(
15615
15631
  const localScaleX = 1 / sx;
15616
15632
  const localScaleY = 1 / sy;
15617
15633
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
15618
- const selectionMatrix = (_g = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _g.call(activeObj);
15634
+ const selectionMatrix = (_h = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _h.call(activeObj);
15619
15635
  const localCenter = selectionMatrix ? fabric__namespace.util.transformPoint(preBakeCenter, fabric__namespace.util.invertTransform(selectionMatrix)) : preBakeCenter;
15620
15636
  const localWidth = bakedW * localScaleX;
15621
15637
  const localHeight = bakedH * localScaleY;
@@ -15740,7 +15756,7 @@ const PageCanvas = react.forwardRef(
15740
15756
  const localScaleX = 1 / sx;
15741
15757
  const localScaleY = 1 / sy;
15742
15758
  obj.set({ scaleX: localScaleX, scaleY: localScaleY });
15743
- const selectionMatrix = (_h = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _h.call(activeObj);
15759
+ const selectionMatrix = (_i = activeObj == null ? void 0 : activeObj.calcTransformMatrix) == null ? void 0 : _i.call(activeObj);
15744
15760
  const localCenter = selectionMatrix ? fabric__namespace.util.transformPoint(preBakeCenter, fabric__namespace.util.invertTransform(selectionMatrix)) : preBakeCenter;
15745
15761
  const localWidth = bakedWidth * localScaleX;
15746
15762
  const localHeight = (obj.height ?? intrinsicHeight) * localScaleY;
@@ -15948,7 +15964,7 @@ const PageCanvas = react.forwardRef(
15948
15964
  updateElement(objId, elementUpdate, { recordHistory: false, skipLayoutRecalc: true });
15949
15965
  obj.setCoords();
15950
15966
  }
15951
- const pageChildrenForReflow = ((_i = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _i.children) ?? [];
15967
+ const pageChildrenForReflow = ((_j = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId)) == null ? void 0 : _j.children) ?? [];
15952
15968
  const stackGroupsToReflow = /* @__PURE__ */ new Set();
15953
15969
  for (const id of modifiedIdsThisRound) {
15954
15970
  const parent = findParentGroup(pageChildrenForReflow, id);
@@ -16027,7 +16043,7 @@ const PageCanvas = react.forwardRef(
16027
16043
  }
16028
16044
  fabricCanvas.setActiveObject(newSel);
16029
16045
  try {
16030
- (_j = newSel.triggerLayout) == null ? void 0 : _j.call(newSel);
16046
+ (_k = newSel.triggerLayout) == null ? void 0 : _k.call(newSel);
16031
16047
  } catch {
16032
16048
  }
16033
16049
  try {
@@ -25137,9 +25153,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
25137
25153
  }
25138
25154
  return svgString;
25139
25155
  }
25140
- const resolvedPackageVersion = "0.5.402";
25156
+ const resolvedPackageVersion = "0.5.404";
25141
25157
  const PACKAGE_VERSION = resolvedPackageVersion;
25142
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.402";
25158
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.404";
25143
25159
  const roundParityValue = (value) => {
25144
25160
  if (typeof value !== "number") return value;
25145
25161
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -25953,7 +25969,7 @@ class PixldocsRenderer {
25953
25969
  await this.waitForCanvasScene(container, cloned, i);
25954
25970
  }
25955
25971
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
25956
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CuA61scC.cjs"));
25972
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CMUgVgvn.cjs"));
25957
25973
  const prepared = preparePagesForExport(
25958
25974
  cloned.pages,
25959
25975
  canvasWidth,
@@ -28273,7 +28289,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
28273
28289
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
28274
28290
  sanitizeSvgTreeForPdf(svgToDraw);
28275
28291
  try {
28276
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CuA61scC.cjs"));
28292
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CMUgVgvn.cjs"));
28277
28293
  try {
28278
28294
  await logTextMeasurementDiagnostic(svgToDraw);
28279
28295
  } catch {
@@ -28670,4 +28686,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
28670
28686
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
28671
28687
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
28672
28688
  exports.warmTemplateFromForm = warmTemplateFromForm;
28673
- //# sourceMappingURL=index-CkhKSrXp.cjs.map
28689
+ //# sourceMappingURL=index-BsKKxOH4.cjs.map