@pixldocs/canvas-renderer 0.5.54 → 0.5.56
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.cjs +58 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +44 -8
- package/dist/index.js +58 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5289,6 +5289,10 @@ function createText(element) {
|
|
|
5289
5289
|
const splitByGrapheme = overflowPolicy === "auto-shrink" ? false : element.splitByGrapheme ?? element.wordWrap === "break-word";
|
|
5290
5290
|
if (overflowPolicy === "auto-shrink") {
|
|
5291
5291
|
const explicitLineCount = Math.max(1, text.split("\n").length);
|
|
5292
|
+
const debugAutoShrink = typeof window !== "undefined" && window.__pixldocsDebugAutoShrink === true;
|
|
5293
|
+
const startFontSize = fontSize;
|
|
5294
|
+
let breakReason = "min-font-size-reached";
|
|
5295
|
+
let lastIter = null;
|
|
5292
5296
|
while (fontSize > 1) {
|
|
5293
5297
|
const testTextbox = new fabric__namespace.Textbox(text, {
|
|
5294
5298
|
width: fixedWidth,
|
|
@@ -5310,11 +5314,47 @@ function createText(element) {
|
|
|
5310
5314
|
const lineWidths = testTextbox.__lineWidths;
|
|
5311
5315
|
const maxLineWidth = lineWidths && lineWidths.length > 0 ? Math.max(...lineWidths) : 0;
|
|
5312
5316
|
const fitsWidth = !widthDidGrow && maxLineWidth <= fixedWidth + 1;
|
|
5317
|
+
if (debugAutoShrink) {
|
|
5318
|
+
lastIter = {
|
|
5319
|
+
fontSize,
|
|
5320
|
+
renderedLineCount,
|
|
5321
|
+
explicitLineCount,
|
|
5322
|
+
textHeight,
|
|
5323
|
+
maxLineWidth,
|
|
5324
|
+
fixedWidth,
|
|
5325
|
+
widthDidGrow,
|
|
5326
|
+
hasNoImplicitWrap,
|
|
5327
|
+
fitsHeight,
|
|
5328
|
+
fitsWidth
|
|
5329
|
+
};
|
|
5330
|
+
}
|
|
5313
5331
|
if (hasNoImplicitWrap && fitsHeight && fitsWidth) {
|
|
5332
|
+
breakReason = "fits";
|
|
5314
5333
|
break;
|
|
5315
5334
|
}
|
|
5316
5335
|
fontSize--;
|
|
5317
5336
|
}
|
|
5337
|
+
if (debugAutoShrink) {
|
|
5338
|
+
console.log("[auto-shrink][diag]", {
|
|
5339
|
+
id: element.id,
|
|
5340
|
+
name: element.name,
|
|
5341
|
+
text,
|
|
5342
|
+
fontFamily: element.fontFamily,
|
|
5343
|
+
fontWeight: element.fontWeight,
|
|
5344
|
+
elementWidth: element.width,
|
|
5345
|
+
elementHeight: element.height,
|
|
5346
|
+
scaleX: element.scaleX ?? 1,
|
|
5347
|
+
scaleY: element.scaleY ?? 1,
|
|
5348
|
+
fixedWidth,
|
|
5349
|
+
baseHeight,
|
|
5350
|
+
startFontSize,
|
|
5351
|
+
finalFontSize: fontSize,
|
|
5352
|
+
breakReason,
|
|
5353
|
+
lastIter,
|
|
5354
|
+
fontCheckRegular: typeof document !== "undefined" && document.fonts ? document.fonts.check(`16px "${element.fontFamily || "Open Sans"}"`) : null,
|
|
5355
|
+
fontCheckBold: typeof document !== "undefined" && document.fonts ? document.fonts.check(`bold 16px "${element.fontFamily || "Open Sans"}"`) : null
|
|
5356
|
+
});
|
|
5357
|
+
}
|
|
5318
5358
|
}
|
|
5319
5359
|
if (overflowPolicy === "max-lines-ellipsis") {
|
|
5320
5360
|
const originalText = element.text || "Text";
|
|
@@ -11693,8 +11733,8 @@ function deriveRepeatablePagesFromTemplate(config, inlineFormSchema, formData) {
|
|
|
11693
11733
|
return out;
|
|
11694
11734
|
}
|
|
11695
11735
|
async function resolveTemplateData(options) {
|
|
11696
|
-
const { templateId, formData, supabaseUrl, supabaseAnonKey } = options;
|
|
11697
|
-
const template = await fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId);
|
|
11736
|
+
const { templateId, formData, supabaseUrl, supabaseAnonKey, prefetched } = options;
|
|
11737
|
+
const template = (prefetched == null ? void 0 : prefetched.templateRow) ? prefetched.templateRow : await fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId);
|
|
11698
11738
|
let config = template.config;
|
|
11699
11739
|
const inlineFormSchema = template.form_schema;
|
|
11700
11740
|
const defaultData = template.default_data;
|
|
@@ -11761,7 +11801,16 @@ async function resolveTemplateData(options) {
|
|
|
11761
11801
|
}
|
|
11762
11802
|
async function resolveFromForm(options) {
|
|
11763
11803
|
var _a, _b, _c;
|
|
11764
|
-
const { templateId, formSchemaId, sectionState, themeId, supabaseUrl, supabaseAnonKey, prefetched } = options;
|
|
11804
|
+
const { templateId, formSchemaId, sectionState, flatFormData: directFlatFormData, themeId, supabaseUrl, supabaseAnonKey, prefetched } = options;
|
|
11805
|
+
if (!formSchemaId) {
|
|
11806
|
+
return resolveTemplateData({
|
|
11807
|
+
templateId,
|
|
11808
|
+
formData: directFlatFormData ?? sectionState ?? {},
|
|
11809
|
+
supabaseUrl,
|
|
11810
|
+
supabaseAnonKey,
|
|
11811
|
+
prefetched: (prefetched == null ? void 0 : prefetched.templateRow) ? { templateRow: prefetched.templateRow } : void 0
|
|
11812
|
+
});
|
|
11813
|
+
}
|
|
11765
11814
|
const [templateRow, formSchemaRow, defaultForm] = await Promise.all([
|
|
11766
11815
|
(prefetched == null ? void 0 : prefetched.templateRow) ? Promise.resolve(prefetched.templateRow) : fetchRow(supabaseUrl, supabaseAnonKey, "templates", templateId),
|
|
11767
11816
|
(prefetched == null ? void 0 : prefetched.formSchemaRow) !== void 0 ? Promise.resolve(prefetched.formSchemaRow) : fetchRow(supabaseUrl, supabaseAnonKey, "form_schemas", formSchemaId),
|
|
@@ -15471,6 +15520,11 @@ async function warmTemplateFromForm(options) {
|
|
|
15471
15520
|
if (signal == null ? void 0 : signal.aborted) return;
|
|
15472
15521
|
await warmResolvedTemplateForPreview(resolved.config, { signal, imageProxyUrl });
|
|
15473
15522
|
}
|
|
15523
|
+
function setAutoShrinkDebug(enabled) {
|
|
15524
|
+
if (typeof window !== "undefined") {
|
|
15525
|
+
window.__pixldocsDebugAutoShrink = !!enabled;
|
|
15526
|
+
}
|
|
15527
|
+
}
|
|
15474
15528
|
exports.FONT_FALLBACK_DEVANAGARI = FONT_FALLBACK_DEVANAGARI;
|
|
15475
15529
|
exports.FONT_FALLBACK_SYMBOLS = FONT_FALLBACK_SYMBOLS;
|
|
15476
15530
|
exports.FONT_FILES = FONT_FILES;
|
|
@@ -15498,6 +15552,7 @@ exports.resolveFontWeight = resolveFontWeight;
|
|
|
15498
15552
|
exports.resolveFromForm = resolveFromForm;
|
|
15499
15553
|
exports.resolveTemplateData = resolveTemplateData;
|
|
15500
15554
|
exports.rewriteSvgFontsForJsPDF = rewriteSvgFontsForJsPDF;
|
|
15555
|
+
exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
15501
15556
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
15502
15557
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
15503
15558
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|