@pixldocs/canvas-renderer 0.5.467 → 0.5.469
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/dist/{index-JJbf0DOF.cjs → index-C4lq9hLY.cjs} +68 -56
- package/dist/index-C4lq9hLY.cjs.map +1 -0
- package/dist/{index-MX3VJ8nQ.js → index-P777JY1z.js} +68 -56
- package/dist/index-P777JY1z.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-v-hlKrdw.js → vectorPdfExport-CKIO3hJy.js} +4 -4
- package/dist/{vectorPdfExport-v-hlKrdw.js.map → vectorPdfExport-CKIO3hJy.js.map} +1 -1
- package/dist/{vectorPdfExport-CYxG1Qy-.cjs → vectorPdfExport-CUb2Bf6z.cjs} +4 -4
- package/dist/{vectorPdfExport-CYxG1Qy-.cjs.map → vectorPdfExport-CUb2Bf6z.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-JJbf0DOF.cjs.map +0 -1
- package/dist/index-MX3VJ8nQ.js.map +0 -1
|
@@ -5255,22 +5255,6 @@ function updateCoverLayout(g) {
|
|
|
5255
5255
|
if (g.clipPath) {
|
|
5256
5256
|
g.clipPath.dirty = true;
|
|
5257
5257
|
}
|
|
5258
|
-
if (fitContain && g.clipPath) {
|
|
5259
|
-
const clip = g.clipPath;
|
|
5260
|
-
const isSpecialMask = isSvgMaskClipPath(clip) || isLuminanceMaskClipPath(clip) || clip.__svgMask || clip.__edgeFadeMask;
|
|
5261
|
-
if (!isSpecialMask) {
|
|
5262
|
-
const clipW = Math.max(frameW, dispW);
|
|
5263
|
-
const clipH = Math.max(frameH, dispH);
|
|
5264
|
-
if (clip instanceof fabric__namespace.Rect) {
|
|
5265
|
-
const rxRatioCt = Number(ct.rx) || 0;
|
|
5266
|
-
const rxPx = rxRatioCt > 0.5 ? Math.min(rxRatioCt, clipW / 2, clipH / 2) : Math.max(0, Math.min(rxRatioCt * Math.min(clipW, clipH), clipW / 2, clipH / 2));
|
|
5267
|
-
clip.set({ width: clipW, height: clipH, rx: rxPx, ry: rxPx, left: offsetX, top: offsetY });
|
|
5268
|
-
} else if (clip instanceof fabric__namespace.Ellipse) {
|
|
5269
|
-
clip.set({ rx: clipW / 2, ry: clipH / 2, left: offsetX, top: offsetY });
|
|
5270
|
-
}
|
|
5271
|
-
clip.dirty = true;
|
|
5272
|
-
}
|
|
5273
|
-
}
|
|
5274
5258
|
finalizeCropGroupCoords(g);
|
|
5275
5259
|
if (g.canvas) {
|
|
5276
5260
|
g.setCoords();
|
|
@@ -12315,18 +12299,21 @@ const PageCanvas = react.forwardRef(
|
|
|
12315
12299
|
if (id && id !== "__background__") {
|
|
12316
12300
|
const width = (obj.width ?? 0) * (obj.scaleX ?? 1);
|
|
12317
12301
|
const height = (obj.height ?? 0) * (obj.scaleY ?? 1);
|
|
12318
|
-
|
|
12319
|
-
let
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12302
|
+
const angle = obj.angle ?? 0;
|
|
12303
|
+
let left;
|
|
12304
|
+
let top;
|
|
12305
|
+
const centerFn = obj.getCenterPoint;
|
|
12306
|
+
if (typeof centerFn === "function") {
|
|
12307
|
+
const c = centerFn.call(obj);
|
|
12308
|
+
left = c.x - width / 2;
|
|
12309
|
+
top = c.y - height / 2;
|
|
12310
|
+
} else {
|
|
12311
|
+
left = obj.left ?? 0;
|
|
12312
|
+
top = obj.top ?? 0;
|
|
12313
|
+
if (obj.originX === "center") left -= width / 2;
|
|
12314
|
+
if (obj.originY === "center") top -= height / 2;
|
|
12328
12315
|
}
|
|
12329
|
-
result.set(id, { left, top, width, height });
|
|
12316
|
+
result.set(id, { left, top, width, height, angle });
|
|
12330
12317
|
}
|
|
12331
12318
|
});
|
|
12332
12319
|
return result;
|
|
@@ -17501,6 +17488,17 @@ const PageCanvas = react.forwardRef(
|
|
|
17501
17488
|
const fadeKeyChanged = newFadeKey !== oldFadeKey || newFadeKey !== innerOldKey || cropFadeRendererMissing;
|
|
17502
17489
|
const needsReload = sourceUrlChanged || colorMapChanged || fadeKeyChanged && !isCropGroup2;
|
|
17503
17490
|
const needsCropGroupFadeUpdate = isCropGroup2 && fadeKeyChanged;
|
|
17491
|
+
let cropFrameSizeChanged = false;
|
|
17492
|
+
if (isCropGroup2) {
|
|
17493
|
+
const liveCt = existingObj.__cropData;
|
|
17494
|
+
const liveW = Number(liveCt == null ? void 0 : liveCt.frameW) || 0;
|
|
17495
|
+
const liveH = Number(liveCt == null ? void 0 : liveCt.frameH) || 0;
|
|
17496
|
+
const schemaW = (Number(element.width) || 0) * (Number(element.scaleX) || 1);
|
|
17497
|
+
const schemaH = (Number(element.height) || 0) * (Number(element.scaleY) || 1);
|
|
17498
|
+
if (schemaW > 0 && schemaH > 0 && (Math.abs(schemaW - liveW) > 0.5 || Math.abs(schemaH - liveH) > 0.5)) {
|
|
17499
|
+
cropFrameSizeChanged = true;
|
|
17500
|
+
}
|
|
17501
|
+
}
|
|
17504
17502
|
const hadUrlBefore = storedImageUrl && String(storedImageUrl).trim() !== "";
|
|
17505
17503
|
if (!hasUrl && hadUrlBefore) {
|
|
17506
17504
|
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 };
|
|
@@ -17537,7 +17535,7 @@ const PageCanvas = react.forwardRef(
|
|
|
17537
17535
|
const clipShapeForReplace = element.clipShape ?? ((_g = element.style) == null ? void 0 : _g.imageFrameShape) ?? (isPreviewMode ? "rectangle" : "none");
|
|
17538
17536
|
const needCropGroupForElement = imageFitForReplace !== "fill" || clipShapeForReplace && clipShapeForReplace !== "none";
|
|
17539
17537
|
const plainImageNeedsCropGroup = hasUrl && !isCropGroup2 && existingObj instanceof fabric__namespace.FabricImage && needCropGroupForElement;
|
|
17540
|
-
if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate)) {
|
|
17538
|
+
if (hasUrl && (needsReload || isPlaceholder || plainImageNeedsCropGroup || needsCropGroupFadeUpdate || cropFrameSizeChanged)) {
|
|
17541
17539
|
if (needsReload && !isBeingTransformed && (!wasJustModified || sourceUrlChanged)) {
|
|
17542
17540
|
loadImageAsync2(element, existingObj, fc);
|
|
17543
17541
|
} else if (plainImageNeedsCropGroup) {
|
|
@@ -20251,27 +20249,32 @@ PageCanvas.displayName = "PageCanvas";
|
|
|
20251
20249
|
function buildElementToFieldMap(dynamicFields) {
|
|
20252
20250
|
const map = /* @__PURE__ */ new Map();
|
|
20253
20251
|
if (!dynamicFields) return map;
|
|
20254
|
-
|
|
20252
|
+
const ordered = dynamicFields.map((f, idx) => ({ f, idx })).sort((a, b) => {
|
|
20253
|
+
const ao = a.f.order ?? Number.POSITIVE_INFINITY;
|
|
20254
|
+
const bo = b.f.order ?? Number.POSITIVE_INFINITY;
|
|
20255
|
+
if (ao !== bo) return ao - bo;
|
|
20256
|
+
return a.idx - b.idx;
|
|
20257
|
+
});
|
|
20258
|
+
const push = (elementId, info) => {
|
|
20259
|
+
const list = map.get(elementId);
|
|
20260
|
+
if (list) list.push(info);
|
|
20261
|
+
else map.set(elementId, [info]);
|
|
20262
|
+
};
|
|
20263
|
+
ordered.forEach(({ f: field }, formIndex) => {
|
|
20255
20264
|
if (field.mappings && Array.isArray(field.mappings)) {
|
|
20256
20265
|
for (const mapping of field.mappings) {
|
|
20257
20266
|
if (mapping.elementId) {
|
|
20258
|
-
|
|
20259
|
-
fieldId: field.id,
|
|
20260
|
-
label: field.label
|
|
20261
|
-
});
|
|
20267
|
+
push(mapping.elementId, { fieldId: field.id, label: field.label, formIndex });
|
|
20262
20268
|
}
|
|
20263
20269
|
}
|
|
20264
20270
|
} else if (field.elementIds && Array.isArray(field.elementIds)) {
|
|
20265
20271
|
for (const elementId of field.elementIds) {
|
|
20266
20272
|
if (elementId) {
|
|
20267
|
-
|
|
20268
|
-
fieldId: field.id,
|
|
20269
|
-
label: field.label
|
|
20270
|
-
});
|
|
20273
|
+
push(elementId, { fieldId: field.id, label: field.label, formIndex });
|
|
20271
20274
|
}
|
|
20272
20275
|
}
|
|
20273
20276
|
}
|
|
20274
|
-
}
|
|
20277
|
+
});
|
|
20275
20278
|
return map;
|
|
20276
20279
|
}
|
|
20277
20280
|
function PreviewCanvas({
|
|
@@ -20362,9 +20365,9 @@ function PreviewCanvas({
|
|
|
20362
20365
|
};
|
|
20363
20366
|
}, [config.themeConfig]);
|
|
20364
20367
|
const handleDynamicFieldClick = react.useCallback((elementId) => {
|
|
20365
|
-
const
|
|
20366
|
-
if (
|
|
20367
|
-
onDynamicFieldClick(elementId,
|
|
20368
|
+
const infos = elementToFieldMap.get(elementId);
|
|
20369
|
+
if (infos && infos.length && onDynamicFieldClick) {
|
|
20370
|
+
onDynamicFieldClick(elementId, infos.map((i) => i.fieldId));
|
|
20368
20371
|
}
|
|
20369
20372
|
}, [elementToFieldMap, onDynamicFieldClick]);
|
|
20370
20373
|
const dynamicFieldElements = react.useMemo(() => {
|
|
@@ -20372,10 +20375,14 @@ function PreviewCanvas({
|
|
|
20372
20375
|
const seenIds = /* @__PURE__ */ new Set();
|
|
20373
20376
|
for (const element of elements) {
|
|
20374
20377
|
if (seenIds.has(element.id)) continue;
|
|
20375
|
-
const
|
|
20376
|
-
if (
|
|
20378
|
+
const infos = elementToFieldMap.get(element.id);
|
|
20379
|
+
if (infos && infos.length) {
|
|
20377
20380
|
seenIds.add(element.id);
|
|
20378
|
-
result.push({
|
|
20381
|
+
result.push({
|
|
20382
|
+
element,
|
|
20383
|
+
label: infos[0].label,
|
|
20384
|
+
extraCount: Math.max(0, infos.length - 1)
|
|
20385
|
+
});
|
|
20379
20386
|
}
|
|
20380
20387
|
}
|
|
20381
20388
|
return result;
|
|
@@ -20449,7 +20456,7 @@ function PreviewCanvas({
|
|
|
20449
20456
|
onReady
|
|
20450
20457
|
}
|
|
20451
20458
|
),
|
|
20452
|
-
onDynamicFieldClick && dynamicFieldElements.map(({ element, label }) => {
|
|
20459
|
+
onDynamicFieldClick && dynamicFieldElements.map(({ element, label, extraCount }) => {
|
|
20453
20460
|
const bounds = actualBounds.get(element.id);
|
|
20454
20461
|
const isHovered = hoveredFieldId === element.id;
|
|
20455
20462
|
let left, top, width, height;
|
|
@@ -20476,22 +20483,27 @@ function PreviewCanvas({
|
|
|
20476
20483
|
border: isHovered ? "2px solid rgb(59 130 246)" : "none",
|
|
20477
20484
|
backgroundColor: isHovered ? "rgba(59, 130, 246, 0.1)" : "transparent",
|
|
20478
20485
|
borderRadius: 4,
|
|
20479
|
-
pointerEvents: "auto"
|
|
20486
|
+
pointerEvents: "auto",
|
|
20487
|
+
transform: (bounds == null ? void 0 : bounds.angle) ? `rotate(${bounds.angle}deg)` : void 0,
|
|
20488
|
+
transformOrigin: "center center"
|
|
20480
20489
|
},
|
|
20481
20490
|
onMouseEnter: () => setHoveredFieldId(element.id),
|
|
20482
20491
|
onMouseLeave: () => setHoveredFieldId(null),
|
|
20483
20492
|
onClick: () => {
|
|
20484
|
-
const
|
|
20485
|
-
if (
|
|
20486
|
-
onDynamicFieldClick(element.id,
|
|
20493
|
+
const infos = elementToFieldMap.get(element.id);
|
|
20494
|
+
if (infos && infos.length && onDynamicFieldClick) {
|
|
20495
|
+
onDynamicFieldClick(element.id, infos.map((i) => i.fieldId));
|
|
20487
20496
|
}
|
|
20488
20497
|
},
|
|
20489
|
-
children: isHovered && /* @__PURE__ */ jsxRuntime.
|
|
20498
|
+
children: isHovered && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
20490
20499
|
"div",
|
|
20491
20500
|
{
|
|
20492
20501
|
className: "absolute -top-6 left-0 bg-primary text-primary-foreground text-xs px-2 py-0.5 rounded shadow-sm whitespace-nowrap",
|
|
20493
20502
|
style: { fontSize: 10 },
|
|
20494
|
-
children:
|
|
20503
|
+
children: [
|
|
20504
|
+
label,
|
|
20505
|
+
extraCount > 0 ? ` +${extraCount} more` : ""
|
|
20506
|
+
]
|
|
20495
20507
|
}
|
|
20496
20508
|
)
|
|
20497
20509
|
},
|
|
@@ -26313,9 +26325,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
26313
26325
|
}
|
|
26314
26326
|
return svgString;
|
|
26315
26327
|
}
|
|
26316
|
-
const resolvedPackageVersion = "0.5.
|
|
26328
|
+
const resolvedPackageVersion = "0.5.469";
|
|
26317
26329
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
26318
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
26330
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.469";
|
|
26319
26331
|
const roundParityValue = (value) => {
|
|
26320
26332
|
if (typeof value !== "number") return value;
|
|
26321
26333
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -27129,7 +27141,7 @@ class PixldocsRenderer {
|
|
|
27129
27141
|
await this.waitForCanvasScene(container, cloned, i);
|
|
27130
27142
|
}
|
|
27131
27143
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
27132
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
27144
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-CUb2Bf6z.cjs"));
|
|
27133
27145
|
const prepared = preparePagesForExport(
|
|
27134
27146
|
cloned.pages,
|
|
27135
27147
|
canvasWidth,
|
|
@@ -29449,7 +29461,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
29449
29461
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
29450
29462
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
29451
29463
|
try {
|
|
29452
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
29464
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-CUb2Bf6z.cjs"));
|
|
29453
29465
|
try {
|
|
29454
29466
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
29455
29467
|
} catch {
|
|
@@ -29763,4 +29775,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
29763
29775
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
29764
29776
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
29765
29777
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
29766
|
-
//# sourceMappingURL=index-
|
|
29778
|
+
//# sourceMappingURL=index-C4lq9hLY.cjs.map
|