@pixldocs/canvas-renderer 0.5.179 → 0.5.180
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.
- package/README.md +42 -0
- package/dist/{index-BBOaToIA.cjs → index-B9NOXCTL.cjs} +148 -10
- package/dist/index-B9NOXCTL.cjs.map +1 -0
- package/dist/{index-C3W71an-.js → index-DdrxSxRr.js} +148 -10
- package/dist/index-DdrxSxRr.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-Be8MJ_2c.cjs → vectorPdfExport-B8qiTpn8.cjs} +4 -4
- package/dist/{vectorPdfExport-Be8MJ_2c.cjs.map → vectorPdfExport-B8qiTpn8.cjs.map} +1 -1
- package/dist/{vectorPdfExport-FmQQMHmX.js → vectorPdfExport-DCZJhOmn.js} +4 -4
- package/dist/{vectorPdfExport-FmQQMHmX.js.map → vectorPdfExport-DCZJhOmn.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BBOaToIA.cjs.map +0 -1
- package/dist/index-C3W71an-.js.map +0 -1
|
@@ -466,9 +466,19 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
|
|
|
466
466
|
const gap = group.stackSpacing ?? 8;
|
|
467
467
|
const padTop = group.paddingTop ?? 0;
|
|
468
468
|
const padLeft = group.paddingLeft ?? 0;
|
|
469
|
+
const padRight = group.paddingRight ?? 0;
|
|
470
|
+
const padBottom = group.paddingBottom ?? 0;
|
|
471
|
+
const justify = group.justifyContent ?? "start";
|
|
472
|
+
const align = group.alignItems ?? "start";
|
|
473
|
+
const isVertical = isVerticalStackLayoutMode(mode);
|
|
469
474
|
const kids = group.children ?? [];
|
|
470
475
|
const out = /* @__PURE__ */ new Map();
|
|
471
|
-
|
|
476
|
+
const sizes = /* @__PURE__ */ new Map();
|
|
477
|
+
for (const c of kids) {
|
|
478
|
+
const b = getNodeBounds(c, pageChildren);
|
|
479
|
+
sizes.set(c.id, { width: b.width, height: b.height });
|
|
480
|
+
}
|
|
481
|
+
if (isVertical) {
|
|
472
482
|
let prevBottom = padTop;
|
|
473
483
|
let firstSeen = false;
|
|
474
484
|
for (let i = 0; i < kids.length; i++) {
|
|
@@ -480,7 +490,7 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
|
|
|
480
490
|
const effectiveTop = !firstSeen ? padTop + storedTop + mTop : prevBottom + gap + storedTop + mTop;
|
|
481
491
|
firstSeen = true;
|
|
482
492
|
out.set(child.id, { top: effectiveTop, left: padLeft + storedLeft + mLeft });
|
|
483
|
-
const h =
|
|
493
|
+
const h = sizes.get(child.id).height;
|
|
484
494
|
prevBottom = effectiveTop + h + (child.marginBottom ?? 0);
|
|
485
495
|
}
|
|
486
496
|
} else {
|
|
@@ -495,10 +505,99 @@ function resolveStackGroupEffectivePositions(group, pageChildren, options) {
|
|
|
495
505
|
const effectiveLeft = !firstSeen ? padLeft + storedLeft + mLeft : prevRight + gap + storedLeft + mLeft;
|
|
496
506
|
firstSeen = true;
|
|
497
507
|
out.set(child.id, { top: padTop + storedTop + mTop, left: effectiveLeft });
|
|
498
|
-
const w =
|
|
508
|
+
const w = sizes.get(child.id).width;
|
|
499
509
|
prevRight = effectiveLeft + w + (child.marginRight ?? 0);
|
|
500
510
|
}
|
|
501
511
|
}
|
|
512
|
+
const containerW = typeof group.width === "number" ? group.width : void 0;
|
|
513
|
+
const containerH = typeof group.height === "number" ? group.height : void 0;
|
|
514
|
+
const mainContainer = isVertical ? containerH : containerW;
|
|
515
|
+
const crossContainer = isVertical ? containerW : containerH;
|
|
516
|
+
if (align !== "start" && crossContainer != null && kids.length > 0) {
|
|
517
|
+
const crossPad0 = isVertical ? padLeft : padTop;
|
|
518
|
+
const crossPadEnd = isVertical ? padRight : padBottom;
|
|
519
|
+
const innerCross = Math.max(0, crossContainer - crossPad0 - crossPadEnd);
|
|
520
|
+
for (const child of kids) {
|
|
521
|
+
const pos = out.get(child.id);
|
|
522
|
+
if (!pos) continue;
|
|
523
|
+
const sz = sizes.get(child.id);
|
|
524
|
+
const childCross = isVertical ? sz.width : sz.height;
|
|
525
|
+
let crossPos;
|
|
526
|
+
if (align === "stretch") {
|
|
527
|
+
crossPos = crossPad0;
|
|
528
|
+
} else if (align === "center") {
|
|
529
|
+
crossPos = crossPad0 + (innerCross - childCross) / 2;
|
|
530
|
+
} else {
|
|
531
|
+
crossPos = crossPad0 + (innerCross - childCross);
|
|
532
|
+
}
|
|
533
|
+
if (isVertical) {
|
|
534
|
+
out.set(child.id, { top: pos.top, left: crossPos });
|
|
535
|
+
} else {
|
|
536
|
+
out.set(child.id, { top: crossPos, left: pos.left });
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (justify !== "start" && mainContainer != null && kids.length > 0) {
|
|
541
|
+
const mainPad0 = isVertical ? padTop : padLeft;
|
|
542
|
+
const mainPadEnd = isVertical ? padBottom : padRight;
|
|
543
|
+
const innerMain = Math.max(0, mainContainer - mainPad0 - mainPadEnd);
|
|
544
|
+
let totalMain = 0;
|
|
545
|
+
for (let i = 0; i < kids.length; i++) {
|
|
546
|
+
const child = kids[i];
|
|
547
|
+
const sz = sizes.get(child.id);
|
|
548
|
+
totalMain += isVertical ? sz.height : sz.width;
|
|
549
|
+
const marginStart = isVertical ? child.marginTop ?? 0 : child.marginLeft ?? 0;
|
|
550
|
+
const marginEnd = isVertical ? child.marginBottom ?? 0 : child.marginRight ?? 0;
|
|
551
|
+
totalMain += marginStart + marginEnd;
|
|
552
|
+
}
|
|
553
|
+
const baseGapTotal = gap * Math.max(0, kids.length - 1);
|
|
554
|
+
const free = innerMain - totalMain - baseGapTotal;
|
|
555
|
+
let offset = 0;
|
|
556
|
+
let extraGap = 0;
|
|
557
|
+
if (free > 0) {
|
|
558
|
+
switch (justify) {
|
|
559
|
+
case "center":
|
|
560
|
+
offset = free / 2;
|
|
561
|
+
break;
|
|
562
|
+
case "end":
|
|
563
|
+
offset = free;
|
|
564
|
+
break;
|
|
565
|
+
case "space-between":
|
|
566
|
+
if (kids.length > 1) extraGap = free / (kids.length - 1);
|
|
567
|
+
else offset = free / 2;
|
|
568
|
+
break;
|
|
569
|
+
case "space-around":
|
|
570
|
+
if (kids.length > 0) {
|
|
571
|
+
extraGap = free / kids.length;
|
|
572
|
+
offset = extraGap / 2;
|
|
573
|
+
}
|
|
574
|
+
break;
|
|
575
|
+
case "space-evenly":
|
|
576
|
+
extraGap = free / (kids.length + 1);
|
|
577
|
+
offset = extraGap;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (offset !== 0 || extraGap !== 0) {
|
|
582
|
+
let cursor = mainPad0 + offset;
|
|
583
|
+
for (let i = 0; i < kids.length; i++) {
|
|
584
|
+
const child = kids[i];
|
|
585
|
+
const sz = sizes.get(child.id);
|
|
586
|
+
const marginStart = isVertical ? child.marginTop ?? 0 : child.marginLeft ?? 0;
|
|
587
|
+
const marginEnd = isVertical ? child.marginBottom ?? 0 : child.marginRight ?? 0;
|
|
588
|
+
const main = isVertical ? sz.height : sz.width;
|
|
589
|
+
const pos = out.get(child.id);
|
|
590
|
+
if (!pos) continue;
|
|
591
|
+
const startMain = cursor + marginStart;
|
|
592
|
+
if (isVertical) {
|
|
593
|
+
out.set(child.id, { top: startMain, left: pos.left });
|
|
594
|
+
} else {
|
|
595
|
+
out.set(child.id, { top: pos.top, left: startMain });
|
|
596
|
+
}
|
|
597
|
+
cursor = startMain + main + marginEnd + gap + extraGap;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
502
601
|
return out;
|
|
503
602
|
}
|
|
504
603
|
function groupBoundsFromChildren(group, pageChildren, options) {
|
|
@@ -7599,7 +7698,28 @@ const PageCanvas = forwardRef(
|
|
|
7599
7698
|
const element = id ? elementById.get(id) : void 0;
|
|
7600
7699
|
if (!element) return;
|
|
7601
7700
|
if (element.overflowPolicy === "auto-shrink") {
|
|
7701
|
+
try {
|
|
7702
|
+
const measured = createText(element);
|
|
7703
|
+
const newFontSize = measured.fontSize;
|
|
7704
|
+
const newWidth = measured.width;
|
|
7705
|
+
const currentFontSize = obj.fontSize;
|
|
7706
|
+
if (typeof newFontSize === "number" && newFontSize > 0 && newFontSize !== currentFontSize) {
|
|
7707
|
+
obj.set({ fontSize: newFontSize });
|
|
7708
|
+
if (typeof newWidth === "number" && newWidth > 0) {
|
|
7709
|
+
obj.width = newWidth;
|
|
7710
|
+
}
|
|
7711
|
+
obj.initDimensions();
|
|
7712
|
+
obj.setCoords();
|
|
7713
|
+
didReflow = true;
|
|
7714
|
+
}
|
|
7715
|
+
} catch {
|
|
7716
|
+
}
|
|
7602
7717
|
obj.dirty = true;
|
|
7718
|
+
try {
|
|
7719
|
+
obj._forceClearCache = true;
|
|
7720
|
+
if (typeof obj._clearCache === "function") obj._clearCache();
|
|
7721
|
+
} catch {
|
|
7722
|
+
}
|
|
7603
7723
|
return;
|
|
7604
7724
|
}
|
|
7605
7725
|
const targetWidth = Math.max(1, Number(element.width) > 0 ? Number(element.width) : Number(obj.width ?? 200));
|
|
@@ -9212,9 +9332,26 @@ const PageCanvas = forwardRef(
|
|
|
9212
9332
|
const needsCropGroupFadeUpdate = isCropGroup2 && fadeKeyChanged;
|
|
9213
9333
|
const hadUrlBefore = storedImageUrl && String(storedImageUrl).trim() !== "";
|
|
9214
9334
|
if (!hasUrl && hadUrlBefore) {
|
|
9215
|
-
const
|
|
9335
|
+
const resolvedSizeImg = (pageChildren == null ? void 0 : pageChildren.length) ? getNodeBounds(element, pageChildren) : { width: typeof element.width === "number" ? element.width : 200, height: typeof element.height === "number" ? element.height : 50 };
|
|
9336
|
+
const hasExplicitSize = typeof element.width === "number" && Number.isFinite(element.width) && element.width > 0 && typeof element.height === "number" && Number.isFinite(element.height) && element.height > 0;
|
|
9337
|
+
const minVisiblePlaceholder = hasExplicitSize ? 1 : 20;
|
|
9338
|
+
const nextWidth = Math.max(minVisiblePlaceholder, Number(resolvedSizeImg.width) || 200);
|
|
9339
|
+
const nextHeight = Math.max(minVisiblePlaceholder, Number(resolvedSizeImg.height) || 50);
|
|
9340
|
+
const storePosImg = pageChildren ? (() => {
|
|
9341
|
+
const node = findNodeById(pageChildren, element.id);
|
|
9342
|
+
return node ? getAbsoluteBounds(node, pageChildren) : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
9343
|
+
})() : { left: element.left ?? 0, top: element.top ?? 0 };
|
|
9344
|
+
const elementForPlaceholder = { ...element, width: nextWidth, height: nextHeight };
|
|
9345
|
+
const placeholder = isCropGroup2 ? createImagePlaceholderForGroup(elementForPlaceholder) : createImagePlaceholder(elementForPlaceholder);
|
|
9216
9346
|
setObjectData(placeholder, element.id);
|
|
9217
9347
|
placeholder.__imageSrc = "";
|
|
9348
|
+
placeholder.set({
|
|
9349
|
+
left: storePosImg.left + nextWidth / 2,
|
|
9350
|
+
top: storePosImg.top + nextHeight / 2,
|
|
9351
|
+
originX: "center",
|
|
9352
|
+
originY: "center"
|
|
9353
|
+
});
|
|
9354
|
+
placeholder.setCoords();
|
|
9218
9355
|
const idx = fc.getObjects().indexOf(existingObj);
|
|
9219
9356
|
fc.remove(existingObj);
|
|
9220
9357
|
if (idx >= 0) {
|
|
@@ -11738,7 +11875,8 @@ function formDefSectionsToInferred(schemaSections, repeatableNodeMap) {
|
|
|
11738
11875
|
// Honor minEntries: 0 — start with no entries, user adds via "+ Add" button.
|
|
11739
11876
|
initialEntryCount: minEntries,
|
|
11740
11877
|
parentId,
|
|
11741
|
-
entryNameFieldKey: def.entryNameFieldKey
|
|
11878
|
+
entryNameFieldKey: def.entryNameFieldKey,
|
|
11879
|
+
isRepeatablePage: def.isRepeatablePage
|
|
11742
11880
|
};
|
|
11743
11881
|
if (treeNodeId) section.treeNodeId = treeNodeId;
|
|
11744
11882
|
sections.push(section);
|
|
@@ -16342,9 +16480,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
16342
16480
|
}
|
|
16343
16481
|
return svgString;
|
|
16344
16482
|
}
|
|
16345
|
-
const resolvedPackageVersion = "0.5.
|
|
16483
|
+
const resolvedPackageVersion = "0.5.180";
|
|
16346
16484
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
16347
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
16485
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.180";
|
|
16348
16486
|
const roundParityValue = (value) => {
|
|
16349
16487
|
if (typeof value !== "number") return value;
|
|
16350
16488
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -16846,7 +16984,7 @@ class PixldocsRenderer {
|
|
|
16846
16984
|
await this.waitForCanvasScene(container, cloned, i);
|
|
16847
16985
|
}
|
|
16848
16986
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
16849
|
-
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-
|
|
16987
|
+
const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DCZJhOmn.js");
|
|
16850
16988
|
const prepared = preparePagesForExport(
|
|
16851
16989
|
cloned.pages,
|
|
16852
16990
|
canvasWidth,
|
|
@@ -18991,7 +19129,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
18991
19129
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
18992
19130
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
18993
19131
|
try {
|
|
18994
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-
|
|
19132
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DCZJhOmn.js");
|
|
18995
19133
|
try {
|
|
18996
19134
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
18997
19135
|
} catch {
|
|
@@ -19387,4 +19525,4 @@ export {
|
|
|
19387
19525
|
collectFontDescriptorsFromConfig as y,
|
|
19388
19526
|
collectFontsFromConfig as z
|
|
19389
19527
|
};
|
|
19390
|
-
//# sourceMappingURL=index-
|
|
19528
|
+
//# sourceMappingURL=index-DdrxSxRr.js.map
|