@templatical/import-unlayer 0.42.1 → 0.43.0
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.d.ts +13 -1
- package/dist/index.js +143 -44
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,18 @@ interface UnlayerFontFamily {
|
|
|
27
27
|
label?: string;
|
|
28
28
|
value?: string;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Document-level link styling: colours are strings, flags are booleans.
|
|
32
|
+
* The hover pair has no Templatical field.
|
|
33
|
+
*/
|
|
34
|
+
interface UnlayerLinkStyle {
|
|
35
|
+
body?: boolean;
|
|
36
|
+
inherit?: boolean;
|
|
37
|
+
linkColor?: string;
|
|
38
|
+
linkHoverColor?: string;
|
|
39
|
+
linkUnderline?: boolean;
|
|
40
|
+
linkHoverUnderline?: boolean;
|
|
41
|
+
}
|
|
30
42
|
interface UnlayerBodyValues {
|
|
31
43
|
backgroundColor?: string;
|
|
32
44
|
backgroundImage?: UnlayerBackgroundImage;
|
|
@@ -34,7 +46,7 @@ interface UnlayerBodyValues {
|
|
|
34
46
|
contentAlignment?: string;
|
|
35
47
|
fontFamily?: UnlayerFontFamily;
|
|
36
48
|
textColor?: string;
|
|
37
|
-
linkStyle?:
|
|
49
|
+
linkStyle?: UnlayerLinkStyle;
|
|
38
50
|
preheaderText?: string;
|
|
39
51
|
[key: string]: unknown;
|
|
40
52
|
}
|
package/dist/index.js
CHANGED
|
@@ -95,11 +95,21 @@ function parseBorderObject(border) {
|
|
|
95
95
|
color: parseColor(border.borderTopColor) || "#000000"
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
/**
|
|
99
|
+
* A divider's `width` as a percentage or a px length; a unitless value is px.
|
|
100
|
+
* `undefined` for anything else. The sign survives, so the caller can clamp.
|
|
101
|
+
*/
|
|
102
|
+
function parseDividerWidth(value) {
|
|
103
|
+
if (typeof value === "number") return Number.isFinite(value) ? {
|
|
104
|
+
unit: "px",
|
|
105
|
+
value
|
|
106
|
+
} : void 0;
|
|
107
|
+
const match = value.trim().match(/^(-?\d+(?:\.\d+)?)\s*(%|px)?$/);
|
|
108
|
+
if (!match) return void 0;
|
|
109
|
+
return {
|
|
110
|
+
unit: match[2] === "%" ? "%" : "px",
|
|
111
|
+
value: parseFloat(match[1])
|
|
112
|
+
};
|
|
103
113
|
}
|
|
104
114
|
function parseFontFamily(value) {
|
|
105
115
|
if (!value) return "";
|
|
@@ -173,12 +183,12 @@ function makeStyles(values) {
|
|
|
173
183
|
* Mirrors the BeeFree importer's helper but reads from Unlayer's flat
|
|
174
184
|
* values shape rather than a CSS style record.
|
|
175
185
|
*/
|
|
176
|
-
function inlineStylesToHtml(html, values) {
|
|
186
|
+
function inlineStylesToHtml(html, values, textColor) {
|
|
177
187
|
const spanParts = [];
|
|
178
188
|
const fontSize = parsePxValue(values.fontSize);
|
|
179
189
|
if (fontSize && fontSize !== 16) spanParts.push(`font-size: ${fontSize}px`);
|
|
180
190
|
const color = parseColor(values.color);
|
|
181
|
-
if (color && color !==
|
|
191
|
+
if (color && color !== textColor) spanParts.push(`color: ${color}`);
|
|
182
192
|
const fontWeight = values.fontWeight;
|
|
183
193
|
if (fontWeight !== void 0 && fontWeight !== null && String(fontWeight) !== "normal" && String(fontWeight) !== "400") spanParts.push(`font-weight: ${fontWeight}`);
|
|
184
194
|
const fontFamily = parseFontFamily(values.fontFamily);
|
|
@@ -238,10 +248,10 @@ function ensureParagraphWrapped(html) {
|
|
|
238
248
|
if (/<p[\s>]/i.test(html)) return html;
|
|
239
249
|
return `<p>${html}</p>`;
|
|
240
250
|
}
|
|
241
|
-
function convertText(values) {
|
|
251
|
+
function convertText(values, textColor) {
|
|
242
252
|
const html = ensureParagraphWrapped(values.text ?? "");
|
|
243
253
|
return createParagraphBlock({
|
|
244
|
-
content: inlineStylesToHtml(html, values),
|
|
254
|
+
content: inlineStylesToHtml(html, values, textColor),
|
|
245
255
|
styles: makeStyles(values)
|
|
246
256
|
});
|
|
247
257
|
}
|
|
@@ -260,7 +270,7 @@ function convertHeading(values) {
|
|
|
260
270
|
return createTitleBlock({
|
|
261
271
|
content,
|
|
262
272
|
level: parseHeadingLevel(values.headingType),
|
|
263
|
-
color: parseColor(values.color) ||
|
|
273
|
+
color: parseColor(values.color) || void 0,
|
|
264
274
|
textAlign: toAlign(values.textAlign),
|
|
265
275
|
fontFamily: parseFontFamily(values.fontFamily) || void 0,
|
|
266
276
|
styles: makeStyles(values)
|
|
@@ -307,15 +317,52 @@ function convertButton(values) {
|
|
|
307
317
|
styles: makeStyles(values)
|
|
308
318
|
});
|
|
309
319
|
}
|
|
310
|
-
|
|
320
|
+
/**
|
|
321
|
+
* `"full"` when the divider spans its column: no width, `100%`, or a px width
|
|
322
|
+
* that reaches `room`, the span the column leaves the line. Any other
|
|
323
|
+
* percentage stays a percentage, clamped to 0–100%.
|
|
324
|
+
*/
|
|
325
|
+
function resolveDividerWidth(value, room, notes) {
|
|
326
|
+
const raw = String(value ?? "").trim();
|
|
327
|
+
if (!raw) return "full";
|
|
328
|
+
const parsed = parseDividerWidth(typeof value === "number" ? value : raw);
|
|
329
|
+
if (!parsed) {
|
|
330
|
+
notes.push(`Divider width "${raw}" could not be read; imported as full width.`);
|
|
331
|
+
return "full";
|
|
332
|
+
}
|
|
333
|
+
if (parsed.unit === "%") {
|
|
334
|
+
const percent = Math.min(100, Math.max(0, parsed.value));
|
|
335
|
+
if (percent !== parsed.value) notes.push(`Divider width ${raw} was clamped to ${percent}%.`);
|
|
336
|
+
const share = Math.round(percent * 100) / 100;
|
|
337
|
+
return share === 100 ? "full" : `${share}%`;
|
|
338
|
+
}
|
|
339
|
+
const px = Math.max(0, Math.round(parsed.value));
|
|
340
|
+
if (px !== Math.round(parsed.value)) notes.push(`Divider width ${raw} was clamped to 0px.`);
|
|
341
|
+
return px >= room ? "full" : px;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Unlayer places a partial divider by `textAlign`, centred by default.
|
|
345
|
+
* Templatical centres every divider, so a left- or right-aligned partial one
|
|
346
|
+
* comes back with a note.
|
|
347
|
+
*/
|
|
348
|
+
function convertDivider(values, columnWidth) {
|
|
311
349
|
const border = parseBorderObject(values.border);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
350
|
+
const styles = makeStyles(values);
|
|
351
|
+
const notes = [];
|
|
352
|
+
const room = columnWidth - styles.padding.left - styles.padding.right;
|
|
353
|
+
const width = resolveDividerWidth(values.width, room, notes);
|
|
354
|
+
const align = values.textAlign;
|
|
355
|
+
if (width !== "full" && (align === "left" || align === "right")) notes.push(`Unlayer aligns this divider ${align}; Templatical centres every divider.`);
|
|
356
|
+
return {
|
|
357
|
+
block: createDividerBlock({
|
|
358
|
+
lineStyle: toLineStyle(border.style),
|
|
359
|
+
color: border.color,
|
|
360
|
+
thickness: border.width || 1,
|
|
361
|
+
width,
|
|
362
|
+
styles
|
|
363
|
+
}),
|
|
364
|
+
notes
|
|
365
|
+
};
|
|
319
366
|
}
|
|
320
367
|
function convertSpacer(values) {
|
|
321
368
|
const padding = parsePaddingShorthand(values.containerPadding);
|
|
@@ -377,7 +424,7 @@ function convertMenu(values) {
|
|
|
377
424
|
separator: values.separator || "|",
|
|
378
425
|
separatorColor: "#999999",
|
|
379
426
|
fontSize: parsePxValue(values.fontSize) || 14,
|
|
380
|
-
color: parseColor(values.color) ||
|
|
427
|
+
color: parseColor(values.color) || void 0,
|
|
381
428
|
fontFamily: parseFontFamily(values.fontFamily) || void 0,
|
|
382
429
|
textAlign: toAlign(values.textAlign, "center"),
|
|
383
430
|
styles: makeStyles(values)
|
|
@@ -394,12 +441,14 @@ function convertHtmlFallback(content, comment) {
|
|
|
394
441
|
* Converts a single Unlayer content node to a Templatical block.
|
|
395
442
|
* Returns the block and a report entry.
|
|
396
443
|
*/
|
|
397
|
-
function convertContent(content, warnings) {
|
|
444
|
+
function convertContent(content, warnings, context = {}) {
|
|
398
445
|
const type = content.type;
|
|
399
446
|
const values = content.values ?? {};
|
|
447
|
+
const columnWidth = context.columnWidth ?? 600;
|
|
448
|
+
const textColor = context.textColor ?? "#1a1a1a";
|
|
400
449
|
switch (type) {
|
|
401
450
|
case "text": return {
|
|
402
|
-
block: convertText(values),
|
|
451
|
+
block: convertText(values, textColor),
|
|
403
452
|
entry: {
|
|
404
453
|
unlayerContentType: type,
|
|
405
454
|
templaticalBlockType: "paragraph",
|
|
@@ -430,14 +479,18 @@ function convertContent(content, warnings) {
|
|
|
430
479
|
status: "converted"
|
|
431
480
|
}
|
|
432
481
|
};
|
|
433
|
-
case "divider":
|
|
434
|
-
block
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
482
|
+
case "divider": {
|
|
483
|
+
const { block, notes } = convertDivider(values, columnWidth);
|
|
484
|
+
return {
|
|
485
|
+
block,
|
|
486
|
+
entry: {
|
|
487
|
+
unlayerContentType: type,
|
|
488
|
+
templaticalBlockType: "divider",
|
|
489
|
+
status: notes.length > 0 ? "approximated" : "converted",
|
|
490
|
+
...notes.length > 0 ? { note: notes.join(" ") } : {}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
441
494
|
case "spacer": return {
|
|
442
495
|
block: convertSpacer(values),
|
|
443
496
|
entry: {
|
|
@@ -523,39 +576,77 @@ function resolveColumnLayout(cells, warnings) {
|
|
|
523
576
|
warnings.push(`Row with ${cells.length} columns was flattened to a single column. Unlayer supports arbitrary columns, but Templatical supports up to 3.`);
|
|
524
577
|
return "1";
|
|
525
578
|
}
|
|
579
|
+
/** Each column's share of the body width, by layout. */
|
|
580
|
+
const COLUMN_SHARES = {
|
|
581
|
+
"1": [1],
|
|
582
|
+
"2": [1 / 2, 1 / 2],
|
|
583
|
+
"3": [
|
|
584
|
+
1 / 3,
|
|
585
|
+
1 / 3,
|
|
586
|
+
1 / 3
|
|
587
|
+
],
|
|
588
|
+
"1-2": [1 / 3, 2 / 3],
|
|
589
|
+
"2-1": [2 / 3, 1 / 3]
|
|
590
|
+
};
|
|
591
|
+
/**
|
|
592
|
+
* A column's px width as the renderer draws it: the body width times the
|
|
593
|
+
* column's share, rounded down. A column past the layout's last slot takes
|
|
594
|
+
* the whole body width, the renderer's fallback.
|
|
595
|
+
*/
|
|
596
|
+
function columnWidthAt(layout, bodyWidth, index) {
|
|
597
|
+
return Math.floor(bodyWidth * (COLUMN_SHARES[layout][index] ?? 1));
|
|
598
|
+
}
|
|
526
599
|
/**
|
|
527
600
|
* Converts all contents in a column to Templatical blocks.
|
|
528
601
|
*/
|
|
529
|
-
function convertColumnContents(column, entries, warnings) {
|
|
602
|
+
function convertColumnContents(column, context, entries, warnings) {
|
|
530
603
|
const blocks = [];
|
|
531
604
|
for (const content of column.contents ?? []) {
|
|
532
|
-
const { block, entry } = convertContent(content, warnings);
|
|
605
|
+
const { block, entry } = convertContent(content, warnings, context);
|
|
533
606
|
blocks.push(block);
|
|
534
607
|
entries.push(entry);
|
|
535
608
|
}
|
|
536
609
|
return blocks;
|
|
537
610
|
}
|
|
538
611
|
/**
|
|
612
|
+
* The section's fill. `columnsBackgroundColor` covers the content width, the
|
|
613
|
+
* area a section paints; `backgroundColor` is the band outside it, used only
|
|
614
|
+
* when the row sets no content colour.
|
|
615
|
+
*/
|
|
616
|
+
function resolveRowBackground(row, warnings) {
|
|
617
|
+
const content = parseColor(row.values?.columnsBackgroundColor);
|
|
618
|
+
const band = parseColor(row.values?.backgroundColor);
|
|
619
|
+
if (content && band && content !== band) warnings.push(`Row background ${band} outside the content width was dropped; the section keeps the content background ${content}.`);
|
|
620
|
+
return content || band || void 0;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
539
623
|
* Processes a single Unlayer row into one or more Templatical blocks.
|
|
624
|
+
*
|
|
625
|
+
* Each column's px width derives from `settings.width` and the resolved
|
|
626
|
+
* layout; every block also learns the template's `textColor`.
|
|
540
627
|
*/
|
|
541
|
-
function processRow(row, entries, warnings) {
|
|
628
|
+
function processRow(row, settings, entries, warnings) {
|
|
542
629
|
const columns = row.columns;
|
|
543
630
|
if (!columns || columns.length === 0) return [];
|
|
544
631
|
const layout = resolveColumnLayout(row.cells ?? columns.map(() => 1), warnings);
|
|
632
|
+
const contextAt = (index) => ({
|
|
633
|
+
columnWidth: columnWidthAt(layout, settings.width, index),
|
|
634
|
+
textColor: settings.textColor
|
|
635
|
+
});
|
|
545
636
|
let children;
|
|
546
637
|
if (layout === "1") {
|
|
547
638
|
const merged = [];
|
|
548
|
-
for (const column of columns) merged.push(...convertColumnContents(column, entries, warnings));
|
|
639
|
+
for (const column of columns) merged.push(...convertColumnContents(column, contextAt(0), entries, warnings));
|
|
549
640
|
children = [merged];
|
|
550
|
-
} else children = columns.map((col) => convertColumnContents(col, entries, warnings));
|
|
551
|
-
const
|
|
641
|
+
} else children = columns.map((col, index) => convertColumnContents(col, contextAt(index), entries, warnings));
|
|
642
|
+
const background = resolveRowBackground(row, warnings);
|
|
552
643
|
const padding = parsePaddingShorthand(row.values?.padding);
|
|
553
644
|
return [createSectionBlock({
|
|
554
645
|
columns: layout,
|
|
555
646
|
children,
|
|
556
647
|
styles: {
|
|
557
648
|
padding,
|
|
558
|
-
...
|
|
649
|
+
...background ? { backgroundColor: background } : {}
|
|
559
650
|
}
|
|
560
651
|
})];
|
|
561
652
|
}
|
|
@@ -567,13 +658,20 @@ function extractSettings(template) {
|
|
|
567
658
|
const width = parsePxValue(values.contentWidth);
|
|
568
659
|
const bgColor = parseColor(values.backgroundColor) || "#ffffff";
|
|
569
660
|
const fontFamily = parseFontFamily(values.fontFamily) || "Arial";
|
|
661
|
+
const textColor = parseColor(values.textColor) || "#1a1a1a";
|
|
662
|
+
const linkColor = parseColor(values.linkStyle?.linkColor);
|
|
663
|
+
const underline = values.linkStyle?.linkUnderline;
|
|
664
|
+
const linkUnderline = typeof underline === "boolean" ? underline : true;
|
|
665
|
+
const preheaderText = typeof values.preheaderText === "string" ? values.preheaderText.trim() : "";
|
|
570
666
|
return {
|
|
571
|
-
width: width
|
|
667
|
+
width: width > 0 ? width : 600,
|
|
572
668
|
backgroundColor: bgColor,
|
|
573
|
-
textColor
|
|
574
|
-
linkUnderline
|
|
669
|
+
textColor,
|
|
670
|
+
linkUnderline,
|
|
575
671
|
fontFamily,
|
|
576
|
-
locale: "en"
|
|
672
|
+
locale: "en",
|
|
673
|
+
...linkColor ? { linkColor } : {},
|
|
674
|
+
...preheaderText ? { preheaderText } : {}
|
|
577
675
|
};
|
|
578
676
|
}
|
|
579
677
|
/**
|
|
@@ -602,20 +700,21 @@ function convertUnlayerTemplate(template) {
|
|
|
602
700
|
const blocks = [];
|
|
603
701
|
const headers = template.body.headers ?? [];
|
|
604
702
|
const footers = template.body.footers ?? [];
|
|
703
|
+
const settings = extractSettings(template);
|
|
605
704
|
if (headers.length > 0) {
|
|
606
705
|
warnings.push(`${headers.length} Unlayer header row(s) were imported as regular rows at the top of the template.`);
|
|
607
|
-
for (const row of headers) blocks.push(...processRow(row, entries, warnings));
|
|
706
|
+
for (const row of headers) blocks.push(...processRow(row, settings, entries, warnings));
|
|
608
707
|
}
|
|
609
|
-
for (const row of template.body.rows) blocks.push(...processRow(row, entries, warnings));
|
|
708
|
+
for (const row of template.body.rows) blocks.push(...processRow(row, settings, entries, warnings));
|
|
610
709
|
if (footers.length > 0) {
|
|
611
710
|
warnings.push(`${footers.length} Unlayer footer row(s) were imported as regular rows at the bottom of the template.`);
|
|
612
|
-
for (const row of footers) blocks.push(...processRow(row, entries, warnings));
|
|
711
|
+
for (const row of footers) blocks.push(...processRow(row, settings, entries, warnings));
|
|
613
712
|
}
|
|
614
713
|
return {
|
|
615
714
|
content: {
|
|
616
715
|
...createDefaultTemplateContent(),
|
|
617
716
|
blocks,
|
|
618
|
-
settings
|
|
717
|
+
settings
|
|
619
718
|
},
|
|
620
719
|
report: {
|
|
621
720
|
entries,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/style-parser.ts","../src/block-mapper.ts","../src/converter.ts"],"sourcesContent":["import type { SpacingValue } from \"@templatical/types\";\nimport type { UnlayerBorder, UnlayerFontFamily } from \"./types\";\n\n/**\n * Parses CSS-like style values from Unlayer content values.\n */\n\nexport function parsePxValue(value: string | number | undefined): number {\n if (value === undefined || value === null) return 0;\n if (typeof value === \"number\") return Math.round(value);\n // Single trailing-whitespace group with an optional `px` inside it. The\n // original `\\s*(?:px)?\\s*` had two `\\s*` quantifiers around an optional\n // group, which is the textbook polynomial-ReDoS shape (\"how should the\n // whitespace split across the two quantifiers?\") over inputs like\n // `9 ` with no `px`.\n const match = value.match(/^(-?\\d+(?:\\.\\d+)?)\\s*(?:px\\s*)?$/);\n return match ? Math.round(parseFloat(match[1])) : 0;\n}\n\n/**\n * An image's corner radius in px, or `undefined` for square corners.\n *\n * Accepts a percentage as well as a px length, because `border-radius: 50%` is\n * the idiomatic way to write a circular avatar and the block stores px only. A\n * percentage resolves against the shorter rendered side, which is what turns a\n * square image into a circle and a wide one into a pill.\n *\n * `width` and `height` must be the dimensions actually read from the source. A\n * percentage with neither known is dropped rather than resolved against the\n * caller's fallback width, which would invent a radius the template never\n * expressed. A non-positive result is dropped for the same reason a px `0` is:\n * both mean square, and only absence keeps it out of the exported JSON.\n */\nexport function parseImageBorderRadius(\n value: string | number | undefined,\n width: number | undefined,\n height: number | undefined,\n): number | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value === \"number\") {\n return value > 0 ? Math.round(value) : undefined;\n }\n\n // Deliberately no `-?`: a negative percentage falls through to the px parse,\n // which rejects it too.\n const percent = value.trim().match(/^(\\d+(?:\\.\\d+)?)\\s*%$/);\n if (percent) {\n const side = Math.min(width ?? Infinity, height ?? Infinity);\n if (!Number.isFinite(side)) return undefined;\n const radius = Math.round((parseFloat(percent[1]) / 100) * side);\n return radius > 0 ? radius : undefined;\n }\n\n const px = parsePxValue(value);\n return px > 0 ? px : undefined;\n}\n\nexport function parseColor(value: string | undefined): string {\n if (!value || value === \"transparent\") return \"\";\n\n const trimmed = value.trim();\n\n if (/^#[0-9a-fA-F]{6}$/.test(trimmed)) return trimmed.toLowerCase();\n\n if (/^#[0-9a-fA-F]{3}$/.test(trimmed)) {\n const r = trimmed[1];\n const g = trimmed[2];\n const b = trimmed[3];\n return `#${r}${r}${g}${g}${b}${b}`.toLowerCase();\n }\n\n return trimmed;\n}\n\nexport function parsePaddingShorthand(value: string | undefined): SpacingValue {\n if (!value) return { top: 0, right: 0, bottom: 0, left: 0 };\n\n const parts = value.trim().split(/\\s+/);\n const values = parts.map((p) => parsePxValue(p));\n\n switch (values.length) {\n case 1:\n return {\n top: values[0],\n right: values[0],\n bottom: values[0],\n left: values[0],\n };\n case 2:\n return {\n top: values[0],\n right: values[1],\n bottom: values[0],\n left: values[1],\n };\n case 3:\n return {\n top: values[0],\n right: values[1],\n bottom: values[2],\n left: values[1],\n };\n default:\n return {\n top: values[0],\n right: values[1],\n bottom: values[2],\n left: values[3],\n };\n }\n}\n\nexport function parseBorderObject(border: UnlayerBorder | undefined): {\n width: number;\n style: string;\n color: string;\n} {\n if (!border) return { width: 0, style: \"solid\", color: \"#000000\" };\n return {\n width: parsePxValue(border.borderTopWidth),\n style: border.borderTopStyle || \"solid\",\n color: parseColor(border.borderTopColor) || \"#000000\",\n };\n}\n\nexport function parseWidthPercent(value: string | undefined): number {\n if (!value) return 100;\n const match = value.match(/^(\\d+(?:\\.\\d+)?)\\s*%/);\n if (match) return Math.round(parseFloat(match[1]));\n return 100;\n}\n\nexport function parseFontFamily(\n value: UnlayerFontFamily | string | undefined,\n): string {\n if (!value) return \"\";\n if (typeof value === \"string\") {\n return value.split(\",\")[0].trim().replace(/['\"]/g, \"\");\n }\n if (value.value) return value.value.split(\",\")[0].trim().replace(/['\"]/g, \"\");\n if (value.label) return value.label;\n return \"\";\n}\n","import {\n createTitleBlock,\n createParagraphBlock,\n createImageBlock,\n createButtonBlock,\n createDividerBlock,\n createSpacerBlock,\n createHtmlBlock,\n createSocialIconsBlock,\n createMenuBlock,\n createVideoBlock,\n generateId,\n} from \"@templatical/types\";\nimport type {\n Block,\n HeadingLevel,\n SocialPlatform,\n SocialIcon,\n MenuItemData,\n} from \"@templatical/types\";\nimport type {\n UnlayerContent,\n UnlayerContentValues,\n ImportReportEntry,\n} from \"./types\";\nimport {\n parseImageBorderRadius,\n parsePxValue,\n parseColor,\n parseFontFamily,\n parsePaddingShorthand,\n parseBorderObject,\n parseWidthPercent,\n} from \"./style-parser\";\n\nconst SOCIAL_PLATFORM_MAP: Record<string, SocialPlatform> = {\n facebook: \"facebook\",\n twitter: \"twitter\",\n x: \"twitter\",\n instagram: \"instagram\",\n linkedin: \"linkedin\",\n youtube: \"youtube\",\n tiktok: \"tiktok\",\n pinterest: \"pinterest\",\n email: \"email\",\n mail: \"email\",\n whatsapp: \"whatsapp\",\n telegram: \"telegram\",\n discord: \"discord\",\n snapchat: \"snapchat\",\n reddit: \"reddit\",\n github: \"github\",\n dribbble: \"dribbble\",\n behance: \"behance\",\n};\n\ntype Align = \"left\" | \"center\" | \"right\";\ntype LineStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nfunction toAlign(value: string | undefined, fallback: Align = \"left\"): Align {\n if (value === \"left\" || value === \"center\" || value === \"right\") return value;\n return fallback;\n}\n\n/**\n * Strip every `<…>` from a button label and reject any stray `<` or `>`\n * left behind (e.g. a truncated `<script`). The original\n * `value.replace(/<[^>]*>/g, \"\")` was both polynomial-ReDoS over\n * `<<<<…` inputs and an incomplete sanitizer — an unterminated `<script`\n * would survive the strip. Downstream HTML-escapes the label at render\n * time, but stripping here keeps the imported JSON clean.\n */\nfunction stripTagsPlain(text: string): string {\n let out = \"\";\n let i = 0;\n while (i < text.length) {\n if (text[i] === \"<\") {\n const close = text.indexOf(\">\", i + 1);\n if (close === -1) {\n // Unterminated tag — discard the rest.\n break;\n }\n i = close + 1;\n continue;\n }\n if (text[i] === \">\") {\n i++;\n continue;\n }\n out += text[i];\n i++;\n }\n return out;\n}\n\nfunction toLineStyle(\n value: string | undefined,\n fallback: LineStyle = \"solid\",\n): LineStyle {\n if (value === \"solid\" || value === \"dashed\" || value === \"dotted\")\n return value;\n return fallback;\n}\n\nfunction makeStyles(values: UnlayerContentValues): Block[\"styles\"] {\n const padding = parsePaddingShorthand(values.containerPadding);\n return {\n padding,\n };\n}\n\n/**\n * Apply Unlayer text-level styles as TipTap-compatible inline markup.\n * Mirrors the BeeFree importer's helper but reads from Unlayer's flat\n * values shape rather than a CSS style record.\n */\nfunction inlineStylesToHtml(\n html: string,\n values: UnlayerContentValues,\n): string {\n const spanParts: string[] = [];\n const fontSize = parsePxValue(values.fontSize);\n if (fontSize && fontSize !== 16) spanParts.push(`font-size: ${fontSize}px`);\n const color = parseColor(values.color);\n if (color && color !== \"#1a1a1a\") spanParts.push(`color: ${color}`);\n const fontWeight = values.fontWeight;\n if (\n fontWeight !== undefined &&\n fontWeight !== null &&\n String(fontWeight) !== \"normal\" &&\n String(fontWeight) !== \"400\"\n ) {\n spanParts.push(`font-weight: ${fontWeight}`);\n }\n const fontFamily = parseFontFamily(values.fontFamily);\n if (fontFamily) spanParts.push(`font-family: ${fontFamily}`);\n\n const textAlign = values.textAlign;\n const pStyle =\n textAlign && textAlign !== \"left\" ? `text-align: ${textAlign}` : \"\";\n\n if (!pStyle && spanParts.length === 0) return html;\n\n const spanStyle = spanParts.join(\"; \");\n let result = html;\n\n if (pStyle) {\n result = result\n .replace(/<p style=\"([^\"]*)\">/g, `<p style=\"$1; ${pStyle}\">`)\n .replaceAll(\"<p>\", `<p style=\"${pStyle}\">`);\n }\n\n if (spanStyle) {\n result = wrapParagraphInner(result, spanStyle);\n }\n\n return result;\n}\n\n/**\n * Wrap the inner content of every `<p …>…</p>` with `<span style=\"…\">…</span>`.\n *\n * Hand-rolled linear scanner instead of `/<p([^>]*)>([\\s\\S]*?)<\\/p>/g` because\n * the regex is polynomial-ReDoS: the engine retries `[\\s\\S]*?<\\/p>` at every\n * `<p` start, so inputs like `<p>a<p>a<p>a…` (no `</p>` ever) cost O(n²).\n * The scanner advances `i` monotonically via `indexOf`, keeping the work\n * strictly O(n).\n */\nfunction wrapParagraphInner(html: string, spanStyle: string): string {\n let out = \"\";\n let i = 0;\n while (i < html.length) {\n const open = html.indexOf(\"<p\", i);\n if (open === -1) {\n out += html.substring(i);\n break;\n }\n const afterTagName = html[open + 2];\n if (\n afterTagName !== \">\" &&\n afterTagName !== \" \" &&\n afterTagName !== \"\\t\" &&\n afterTagName !== \"\\n\" &&\n afterTagName !== \"\\r\" &&\n afterTagName !== \"/\"\n ) {\n out += html.substring(i, open + 2);\n i = open + 2;\n continue;\n }\n const openEnd = html.indexOf(\">\", open + 2);\n if (openEnd === -1) {\n out += html.substring(i);\n break;\n }\n const closeStart = html.indexOf(\"</p>\", openEnd + 1);\n if (closeStart === -1) {\n out += html.substring(i);\n break;\n }\n const inner = html.substring(openEnd + 1, closeStart);\n out += html.substring(i, openEnd + 1);\n out += `<span style=\"${spanStyle}\">${inner}</span></p>`;\n i = closeStart + 4;\n }\n return out;\n}\n\nfunction ensureParagraphWrapped(html: string): string {\n if (!html) return \"<p></p>\";\n if (/<p[\\s>]/i.test(html)) return html;\n return `<p>${html}</p>`;\n}\n\nfunction convertText(values: UnlayerContentValues): Block {\n const html = ensureParagraphWrapped(values.text ?? \"\");\n\n return createParagraphBlock({\n content: inlineStylesToHtml(html, values),\n styles: makeStyles(values),\n });\n}\n\nfunction parseHeadingLevel(tag: string | undefined): HeadingLevel {\n if (!tag) return 2;\n const match = tag.match(/^h(\\d)$/i);\n if (match) {\n const num = Number(match[1]);\n if (num >= 1 && num <= 4) return num as HeadingLevel;\n }\n return 2;\n}\n\nfunction convertHeading(values: UnlayerContentValues): Block {\n const text = values.text ?? \"\";\n const stripped = text.replace(/^<h\\d[^>]*>|<\\/h\\d>$/gi, \"\");\n const content = stripped ? `<p>${stripped}</p>` : \"<p></p>\";\n\n return createTitleBlock({\n content,\n level: parseHeadingLevel(values.headingType),\n color: parseColor(values.color) || \"#1a1a1a\",\n textAlign: toAlign(values.textAlign),\n fontFamily: parseFontFamily(values.fontFamily) || undefined,\n styles: makeStyles(values),\n });\n}\n\nfunction convertImage(values: UnlayerContentValues): Block {\n const src = values.src;\n const action = values.action?.values;\n\n // Kept separate from the `?? 600` fallback below: a percentage radius has to\n // resolve against a width the template actually stated.\n const readWidth = src?.width ? Math.round(src.width) : undefined;\n const readHeight = src?.height ? Math.round(src.height) : undefined;\n\n return createImageBlock({\n src: src?.url || \"\",\n alt: values.altText || \"\",\n width: readWidth ?? 600,\n // No default, unlike width: an absent height keeps the aspect ratio.\n height: readHeight,\n borderRadius: parseImageBorderRadius(\n values.borderRadius,\n readWidth,\n readHeight,\n ),\n align: toAlign(values.textAlign, \"center\"),\n linkUrl: action?.href || undefined,\n linkOpenInNewTab: action?.target === \"_blank\" || undefined,\n styles: makeStyles(values),\n });\n}\n\nfunction convertButton(values: UnlayerContentValues): Block {\n const colors = values.buttonColors ?? {};\n const padding = values.padding\n ? parsePaddingShorthand(values.padding)\n : { top: 12, right: 24, bottom: 12, left: 24 };\n const label = stripTagsPlain(values.text ?? \"Button\");\n const linkValues = values.href?.values;\n\n return createButtonBlock({\n text: label,\n url: linkValues?.href || \"#\",\n openInNewTab: linkValues?.target === \"_blank\" || undefined,\n backgroundColor: parseColor(colors.backgroundColor) || \"#4f46e5\",\n textColor: parseColor(colors.color) || \"#ffffff\",\n borderRadius: parsePxValue(values.borderRadius),\n fontSize: parsePxValue(values.fontSize) || 16,\n fontFamily: parseFontFamily(values.fontFamily) || undefined,\n align: toAlign(values.textAlign, \"center\"),\n buttonPadding: padding,\n styles: makeStyles(values),\n });\n}\n\nfunction convertDivider(values: UnlayerContentValues): Block {\n const border = parseBorderObject(values.border);\n\n return createDividerBlock({\n lineStyle: toLineStyle(border.style),\n color: border.color,\n thickness: border.width || 1,\n width: parseWidthPercent(values.width),\n styles: makeStyles(values),\n });\n}\n\nfunction convertSpacer(values: UnlayerContentValues): Block {\n const padding = parsePaddingShorthand(values.containerPadding);\n const height =\n parsePxValue((values as { height?: string | number }).height) ||\n padding.top + padding.bottom ||\n 24;\n\n return createSpacerBlock({\n height,\n styles: makeStyles(values),\n });\n}\n\nfunction convertHtml(values: UnlayerContentValues): Block {\n return createHtmlBlock({\n content: values.html ?? \"\",\n styles: makeStyles(values),\n });\n}\n\nfunction convertSocial(\n values: UnlayerContentValues,\n warnings: string[],\n): Block {\n const iconList = values.icons?.icons ?? [];\n const icons: SocialIcon[] = [];\n\n for (const unlayerIcon of iconList) {\n const id = (unlayerIcon.name ?? \"\").toLowerCase();\n const platform = SOCIAL_PLATFORM_MAP[id];\n\n if (!platform) {\n warnings.push(\n `Unrecognized social icon \"${unlayerIcon.name || id}\" was skipped.`,\n );\n continue;\n }\n\n icons.push({\n id: generateId(),\n platform,\n url: unlayerIcon.url || \"#\",\n });\n }\n\n return createSocialIconsBlock({\n icons,\n align: toAlign(values.textAlign, \"center\"),\n styles: makeStyles(values),\n });\n}\n\nfunction convertVideo(values: UnlayerContentValues): Block {\n return createVideoBlock({\n url: values.videoUrl || \"\",\n thumbnailUrl: values.thumbnailUrl || \"\",\n alt: values.altText || \"\",\n width: 600,\n align: toAlign(values.textAlign, \"center\"),\n styles: makeStyles(values),\n });\n}\n\nfunction convertMenu(values: UnlayerContentValues): Block {\n const menu = values.menu;\n const items: MenuItemData[] = (menu?.items ?? []).map((item) => ({\n id: generateId(),\n text: item.text || \"\",\n url: item.link?.values?.href || \"#\",\n openInNewTab: item.link?.values?.target === \"_blank\",\n bold: false,\n underline: false,\n }));\n\n return createMenuBlock({\n items,\n separator: values.separator || \"|\",\n separatorColor: \"#999999\",\n fontSize: parsePxValue(values.fontSize) || 14,\n color: parseColor(values.color) || \"#1a1a1a\",\n fontFamily: parseFontFamily(values.fontFamily) || undefined,\n textAlign: toAlign(values.textAlign, \"center\"),\n styles: makeStyles(values),\n });\n}\n\nfunction convertHtmlFallback(content: UnlayerContent, comment: string): Block {\n const safe = comment.replace(/</g, \"<\").replace(/>/g, \">\");\n return createHtmlBlock({\n content: `<div style=\"padding:12px;border:1px dashed #d1d5db;border-radius:6px;background:#fafafa;color:#6b7280;font-family:sans-serif;font-size:13px;\">${safe}</div>`,\n styles: makeStyles(content.values),\n });\n}\n\n/**\n * Converts a single Unlayer content node to a Templatical block.\n * Returns the block and a report entry.\n */\nexport function convertContent(\n content: UnlayerContent,\n warnings: string[],\n): { block: Block; entry: ImportReportEntry } {\n const type = content.type;\n const values = content.values ?? ({} as UnlayerContentValues);\n\n switch (type) {\n case \"text\":\n return {\n block: convertText(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"paragraph\",\n status: \"converted\",\n },\n };\n case \"heading\":\n return {\n block: convertHeading(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"title\",\n status: \"converted\",\n },\n };\n case \"image\":\n return {\n block: convertImage(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"image\",\n status: \"converted\",\n },\n };\n case \"button\":\n return {\n block: convertButton(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"button\",\n status: \"converted\",\n },\n };\n case \"divider\":\n return {\n block: convertDivider(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"divider\",\n status: \"converted\",\n },\n };\n case \"spacer\":\n return {\n block: convertSpacer(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"spacer\",\n status: \"converted\",\n },\n };\n case \"html\":\n return {\n block: convertHtml(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"html\",\n status: \"converted\",\n },\n };\n case \"menu\":\n return {\n block: convertMenu(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"menu\",\n status: \"approximated\",\n note: \"Menu styles map approximately; review spacing and separator color.\",\n },\n };\n case \"social\":\n return {\n block: convertSocial(values, warnings),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"social\",\n status: \"converted\",\n },\n };\n case \"video\":\n return {\n block: convertVideo(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"video\",\n status: \"converted\",\n },\n };\n case \"timer\":\n return {\n block: convertHtmlFallback(\n content,\n \"Unlayer timer block: rebuild manually in Templatical\",\n ),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"html\",\n status: \"html-fallback\",\n note: \"Timer modules have no direct Templatical equivalent; placeholder HTML inserted.\",\n },\n };\n case \"form\":\n return {\n block: convertHtmlFallback(\n content,\n \"Unlayer form block: not supported in Templatical (most email clients block form submission)\",\n ),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: null,\n status: \"skipped\",\n note: \"Unlayer forms have no Templatical equivalent and are skipped. Most email clients block form submission anyway.\",\n },\n };\n default:\n return {\n block: convertHtmlFallback(\n content,\n `Unsupported Unlayer content type: ${type}`,\n ),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"html\",\n status: \"html-fallback\",\n note: `Unknown content type \"${type}\" converted to HTML block.`,\n },\n };\n }\n}\n","import {\n createSectionBlock,\n createDefaultTemplateContent,\n} from \"@templatical/types\";\nimport type { Block, ColumnLayout, TemplateContent } from \"@templatical/types\";\nimport type {\n UnlayerTemplate,\n UnlayerRow,\n UnlayerColumn,\n ImportResult,\n ImportReport,\n ImportReportEntry,\n} from \"./types\";\nimport { convertContent } from \"./block-mapper\";\nimport {\n parsePxValue,\n parseColor,\n parseFontFamily,\n parsePaddingShorthand,\n} from \"./style-parser\";\n\nfunction resolveColumnLayout(\n cells: number[],\n warnings: string[],\n): ColumnLayout {\n if (cells.length <= 1) return \"1\";\n if (cells.length === 3) return \"3\";\n\n if (cells.length === 2) {\n const left = cells[0] ?? 1;\n const right = cells[1] ?? 1;\n const total = left + right;\n const ratio = left / total;\n\n if (ratio > 0.58) return \"2-1\";\n if (ratio < 0.42) return \"1-2\";\n return \"2\";\n }\n\n warnings.push(\n `Row with ${cells.length} columns was flattened to a single column. Unlayer supports arbitrary columns, but Templatical supports up to 3.`,\n );\n return \"1\";\n}\n\n/**\n * Converts all contents in a column to Templatical blocks.\n */\nfunction convertColumnContents(\n column: UnlayerColumn,\n entries: ImportReportEntry[],\n warnings: string[],\n): Block[] {\n const blocks: Block[] = [];\n\n for (const content of column.contents ?? []) {\n const { block, entry } = convertContent(content, warnings);\n blocks.push(block);\n entries.push(entry);\n }\n\n return blocks;\n}\n\n/**\n * Processes a single Unlayer row into one or more Templatical blocks.\n */\nfunction processRow(\n row: UnlayerRow,\n entries: ImportReportEntry[],\n warnings: string[],\n): Block[] {\n const columns = row.columns;\n if (!columns || columns.length === 0) return [];\n\n const cells = row.cells ?? columns.map(() => 1);\n const layout = resolveColumnLayout(cells, warnings);\n\n let children: Block[][];\n if (layout === \"1\") {\n const merged: Block[] = [];\n for (const column of columns) {\n merged.push(...convertColumnContents(column, entries, warnings));\n }\n children = [merged];\n } else {\n children = columns.map((col) =>\n convertColumnContents(col, entries, warnings),\n );\n }\n\n const rowBg = parseColor(row.values?.backgroundColor);\n const padding = parsePaddingShorthand(row.values?.padding);\n\n const section = createSectionBlock({\n columns: layout,\n children,\n styles: {\n padding,\n ...(rowBg ? { backgroundColor: rowBg } : {}),\n },\n });\n\n return [section];\n}\n\n/**\n * Extracts template-level settings from the Unlayer body values.\n */\nfunction extractSettings(\n template: UnlayerTemplate,\n): TemplateContent[\"settings\"] {\n const values = template.body?.values ?? {};\n\n const width = parsePxValue(values.contentWidth);\n const bgColor = parseColor(values.backgroundColor) || \"#ffffff\";\n const fontFamily = parseFontFamily(values.fontFamily) || \"Arial\";\n\n return {\n width: width || 600,\n backgroundColor: bgColor,\n textColor: \"#1a1a1a\",\n linkUnderline: false,\n fontFamily,\n locale: \"en\",\n };\n}\n\n/**\n * Converts an Unlayer design JSON to Templatical TemplateContent.\n *\n * @param template - The parsed Unlayer JSON object (the result of `editor.saveDesign(...)`)\n * @returns An ImportResult with the converted content and a detailed report\n *\n * @example\n * ```ts\n * import { convertUnlayerTemplate } from '@templatical/import-unlayer';\n *\n * const unlayerJson = JSON.parse(fileContent);\n * const { content, report } = convertUnlayerTemplate(unlayerJson);\n *\n * const editor = init({ container: '#editor', content });\n *\n * console.log(report.summary);\n * console.log(report.warnings);\n * ```\n */\nexport function convertUnlayerTemplate(\n template: UnlayerTemplate,\n): ImportResult {\n if (!template?.body?.rows) {\n throw new Error(\n \"Invalid Unlayer template: missing body.rows. Ensure you are passing a valid Unlayer JSON design (the output of editor.saveDesign).\",\n );\n }\n\n const entries: ImportReportEntry[] = [];\n const warnings: string[] = [];\n const blocks: Block[] = [];\n\n const headers = template.body.headers ?? [];\n const footers = template.body.footers ?? [];\n\n if (headers.length > 0) {\n warnings.push(\n `${headers.length} Unlayer header row(s) were imported as regular rows at the top of the template.`,\n );\n for (const row of headers) {\n blocks.push(...processRow(row, entries, warnings));\n }\n }\n\n for (const row of template.body.rows) {\n blocks.push(...processRow(row, entries, warnings));\n }\n\n if (footers.length > 0) {\n warnings.push(\n `${footers.length} Unlayer footer row(s) were imported as regular rows at the bottom of the template.`,\n );\n for (const row of footers) {\n blocks.push(...processRow(row, entries, warnings));\n }\n }\n\n const content: TemplateContent = {\n ...createDefaultTemplateContent(),\n blocks,\n settings: extractSettings(template),\n };\n\n const summary = {\n total: entries.length,\n converted: entries.filter((e) => e.status === \"converted\").length,\n approximated: entries.filter((e) => e.status === \"approximated\").length,\n htmlFallback: entries.filter((e) => e.status === \"html-fallback\").length,\n skipped: entries.filter((e) => e.status === \"skipped\").length,\n };\n\n const report: ImportReport = { entries, warnings, summary };\n\n return { content, report };\n}\n"],"mappings":";;;;;AAOA,SAAgB,aAAa,OAA4C;CACvE,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,IAAI,OAAO,UAAU,UAAU,OAAO,KAAK,MAAM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,OAAO,iFACpB;EACA,KAAK,MAAM,OAAO,SAChB,OAAO,KAAK,GAAG,WAAW,KAAK,SAAS,QAAQ,CAAC;CAErD;CAEA,KAAK,MAAM,OAAO,SAAS,KAAK,MAC9B,OAAO,KAAK,GAAG,WAAW,KAAK,SAAS,QAAQ,CAAC;CAGnD,IAAI,QAAQ,SAAS,GAAG;EACtB,SAAS,KACP,GAAG,QAAQ,OAAO,oFACpB;EACA,KAAK,MAAM,OAAO,SAChB,OAAO,KAAK,GAAG,WAAW,KAAK,SAAS,QAAQ,CAAC;CAErD;CAkBA,OAAO;EAAE,SAAA;GAfP,GAAG,6BAA6B;GAChC;GACA,UAAU,gBAAgB,QAAQ;EAarB;EAAG,QAAA;GAFa;GAAS;GAAU,SAAA;IAPhD,OAAO,QAAQ;IACf,WAAW,QAAQ,QAAQ,MAAM,EAAE,WAAW,WAAW,CAAC,CAAC;IAC3D,cAAc,QAAQ,QAAQ,MAAM,EAAE,WAAW,cAAc,CAAC,CAAC;IACjE,cAAc,QAAQ,QAAQ,MAAM,EAAE,WAAW,eAAe,CAAC,CAAC;IAClE,SAAS,QAAQ,QAAQ,MAAM,EAAE,WAAW,SAAS,CAAC,CAAC;GAGD;EAEjC;CAAE;AAC3B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/style-parser.ts","../src/block-mapper.ts","../src/converter.ts"],"sourcesContent":["import type { SpacingValue } from \"@templatical/types\";\nimport type { UnlayerBorder, UnlayerFontFamily } from \"./types\";\n\n/**\n * Parses CSS-like style values from Unlayer content values.\n */\n\nexport function parsePxValue(value: string | number | undefined): number {\n if (value === undefined || value === null) return 0;\n if (typeof value === \"number\") return Math.round(value);\n // Single trailing-whitespace group with an optional `px` inside it. The\n // original `\\s*(?:px)?\\s*` had two `\\s*` quantifiers around an optional\n // group, which is the textbook polynomial-ReDoS shape (\"how should the\n // whitespace split across the two quantifiers?\") over inputs like\n // `9 ` with no `px`.\n const match = value.match(/^(-?\\d+(?:\\.\\d+)?)\\s*(?:px\\s*)?$/);\n return match ? Math.round(parseFloat(match[1])) : 0;\n}\n\n/**\n * An image's corner radius in px, or `undefined` for square corners.\n *\n * Accepts a percentage as well as a px length, because `border-radius: 50%` is\n * the idiomatic way to write a circular avatar and the block stores px only. A\n * percentage resolves against the shorter rendered side, which is what turns a\n * square image into a circle and a wide one into a pill.\n *\n * `width` and `height` must be the dimensions actually read from the source. A\n * percentage with neither known is dropped rather than resolved against the\n * caller's fallback width, which would invent a radius the template never\n * expressed. A non-positive result is dropped for the same reason a px `0` is:\n * both mean square, and only absence keeps it out of the exported JSON.\n */\nexport function parseImageBorderRadius(\n value: string | number | undefined,\n width: number | undefined,\n height: number | undefined,\n): number | undefined {\n if (value === undefined || value === null || value === \"\") return undefined;\n if (typeof value === \"number\") {\n return value > 0 ? Math.round(value) : undefined;\n }\n\n // Deliberately no `-?`: a negative percentage falls through to the px parse,\n // which rejects it too.\n const percent = value.trim().match(/^(\\d+(?:\\.\\d+)?)\\s*%$/);\n if (percent) {\n const side = Math.min(width ?? Infinity, height ?? Infinity);\n if (!Number.isFinite(side)) return undefined;\n const radius = Math.round((parseFloat(percent[1]) / 100) * side);\n return radius > 0 ? radius : undefined;\n }\n\n const px = parsePxValue(value);\n return px > 0 ? px : undefined;\n}\n\nexport function parseColor(value: string | undefined): string {\n if (!value || value === \"transparent\") return \"\";\n\n const trimmed = value.trim();\n\n if (/^#[0-9a-fA-F]{6}$/.test(trimmed)) return trimmed.toLowerCase();\n\n if (/^#[0-9a-fA-F]{3}$/.test(trimmed)) {\n const r = trimmed[1];\n const g = trimmed[2];\n const b = trimmed[3];\n return `#${r}${r}${g}${g}${b}${b}`.toLowerCase();\n }\n\n return trimmed;\n}\n\nexport function parsePaddingShorthand(value: string | undefined): SpacingValue {\n if (!value) return { top: 0, right: 0, bottom: 0, left: 0 };\n\n const parts = value.trim().split(/\\s+/);\n const values = parts.map((p) => parsePxValue(p));\n\n switch (values.length) {\n case 1:\n return {\n top: values[0],\n right: values[0],\n bottom: values[0],\n left: values[0],\n };\n case 2:\n return {\n top: values[0],\n right: values[1],\n bottom: values[0],\n left: values[1],\n };\n case 3:\n return {\n top: values[0],\n right: values[1],\n bottom: values[2],\n left: values[1],\n };\n default:\n return {\n top: values[0],\n right: values[1],\n bottom: values[2],\n left: values[3],\n };\n }\n}\n\nexport function parseBorderObject(border: UnlayerBorder | undefined): {\n width: number;\n style: string;\n color: string;\n} {\n if (!border) return { width: 0, style: \"solid\", color: \"#000000\" };\n return {\n width: parsePxValue(border.borderTopWidth),\n style: border.borderTopStyle || \"solid\",\n color: parseColor(border.borderTopColor) || \"#000000\",\n };\n}\n\n/**\n * A divider's `width` as a percentage or a px length; a unitless value is px.\n * `undefined` for anything else. The sign survives, so the caller can clamp.\n */\nexport function parseDividerWidth(\n value: string | number,\n): { unit: \"%\" | \"px\"; value: number } | undefined {\n if (typeof value === \"number\") {\n return Number.isFinite(value) ? { unit: \"px\", value } : undefined;\n }\n // One `\\s*` before the unit, so there is a single way to match trailing\n // whitespace (see `parsePxValue` for the two-quantifier ReDoS shape).\n const match = value.trim().match(/^(-?\\d+(?:\\.\\d+)?)\\s*(%|px)?$/);\n if (!match) return undefined;\n return { unit: match[2] === \"%\" ? \"%\" : \"px\", value: parseFloat(match[1]) };\n}\n\nexport function parseFontFamily(\n value: UnlayerFontFamily | string | undefined,\n): string {\n if (!value) return \"\";\n if (typeof value === \"string\") {\n return value.split(\",\")[0].trim().replace(/['\"]/g, \"\");\n }\n if (value.value) return value.value.split(\",\")[0].trim().replace(/['\"]/g, \"\");\n if (value.label) return value.label;\n return \"\";\n}\n","import {\n createTitleBlock,\n createParagraphBlock,\n createImageBlock,\n createButtonBlock,\n createDividerBlock,\n createSpacerBlock,\n createHtmlBlock,\n createSocialIconsBlock,\n createMenuBlock,\n createVideoBlock,\n generateId,\n} from \"@templatical/types\";\nimport type {\n Block,\n DividerBlock,\n HeadingLevel,\n SocialPlatform,\n SocialIcon,\n MenuItemData,\n} from \"@templatical/types\";\nimport type {\n UnlayerContent,\n UnlayerContentValues,\n ImportReportEntry,\n} from \"./types\";\nimport {\n parseImageBorderRadius,\n parsePxValue,\n parseColor,\n parseFontFamily,\n parsePaddingShorthand,\n parseBorderObject,\n parseDividerWidth,\n} from \"./style-parser\";\n\nconst SOCIAL_PLATFORM_MAP: Record<string, SocialPlatform> = {\n facebook: \"facebook\",\n twitter: \"twitter\",\n x: \"twitter\",\n instagram: \"instagram\",\n linkedin: \"linkedin\",\n youtube: \"youtube\",\n tiktok: \"tiktok\",\n pinterest: \"pinterest\",\n email: \"email\",\n mail: \"email\",\n whatsapp: \"whatsapp\",\n telegram: \"telegram\",\n discord: \"discord\",\n snapchat: \"snapchat\",\n reddit: \"reddit\",\n github: \"github\",\n dribbble: \"dribbble\",\n behance: \"behance\",\n};\n\n/** The body width when a template's `contentWidth` states no px value. */\nexport const DEFAULT_BODY_WIDTH = 600;\n\n/** The template text colour when the body sets none. */\nexport const FALLBACK_TEXT_COLOR = \"#1a1a1a\";\n\n/**\n * What the caller knows about where a content node lands.\n */\nexport interface ContentContext {\n /**\n * Width in px of the Templatical column the block renders in. Defaults to\n * `DEFAULT_BODY_WIDTH`.\n */\n columnWidth?: number;\n /**\n * The template's `textColor`, which every text block without a colour of\n * its own inherits. Defaults to `FALLBACK_TEXT_COLOR`.\n */\n textColor?: string;\n}\n\ntype Align = \"left\" | \"center\" | \"right\";\ntype LineStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nfunction toAlign(value: string | undefined, fallback: Align = \"left\"): Align {\n if (value === \"left\" || value === \"center\" || value === \"right\") return value;\n return fallback;\n}\n\n/**\n * Strip every `<…>` from a button label and reject any stray `<` or `>`\n * left behind (e.g. a truncated `<script`). The original\n * `value.replace(/<[^>]*>/g, \"\")` was both polynomial-ReDoS over\n * `<<<<…` inputs and an incomplete sanitizer — an unterminated `<script`\n * would survive the strip. Downstream HTML-escapes the label at render\n * time, but stripping here keeps the imported JSON clean.\n */\nfunction stripTagsPlain(text: string): string {\n let out = \"\";\n let i = 0;\n while (i < text.length) {\n if (text[i] === \"<\") {\n const close = text.indexOf(\">\", i + 1);\n if (close === -1) {\n // Unterminated tag — discard the rest.\n break;\n }\n i = close + 1;\n continue;\n }\n if (text[i] === \">\") {\n i++;\n continue;\n }\n out += text[i];\n i++;\n }\n return out;\n}\n\nfunction toLineStyle(\n value: string | undefined,\n fallback: LineStyle = \"solid\",\n): LineStyle {\n if (value === \"solid\" || value === \"dashed\" || value === \"dotted\")\n return value;\n return fallback;\n}\n\nfunction makeStyles(values: UnlayerContentValues): Block[\"styles\"] {\n const padding = parsePaddingShorthand(values.containerPadding);\n return {\n padding,\n };\n}\n\n/**\n * Apply Unlayer text-level styles as TipTap-compatible inline markup.\n * Mirrors the BeeFree importer's helper but reads from Unlayer's flat\n * values shape rather than a CSS style record.\n */\nfunction inlineStylesToHtml(\n html: string,\n values: UnlayerContentValues,\n textColor: string,\n): string {\n const spanParts: string[] = [];\n const fontSize = parsePxValue(values.fontSize);\n if (fontSize && fontSize !== 16) spanParts.push(`font-size: ${fontSize}px`);\n const color = parseColor(values.color);\n if (color && color !== textColor) spanParts.push(`color: ${color}`);\n const fontWeight = values.fontWeight;\n if (\n fontWeight !== undefined &&\n fontWeight !== null &&\n String(fontWeight) !== \"normal\" &&\n String(fontWeight) !== \"400\"\n ) {\n spanParts.push(`font-weight: ${fontWeight}`);\n }\n const fontFamily = parseFontFamily(values.fontFamily);\n if (fontFamily) spanParts.push(`font-family: ${fontFamily}`);\n\n const textAlign = values.textAlign;\n const pStyle =\n textAlign && textAlign !== \"left\" ? `text-align: ${textAlign}` : \"\";\n\n if (!pStyle && spanParts.length === 0) return html;\n\n const spanStyle = spanParts.join(\"; \");\n let result = html;\n\n if (pStyle) {\n result = result\n .replace(/<p style=\"([^\"]*)\">/g, `<p style=\"$1; ${pStyle}\">`)\n .replaceAll(\"<p>\", `<p style=\"${pStyle}\">`);\n }\n\n if (spanStyle) {\n result = wrapParagraphInner(result, spanStyle);\n }\n\n return result;\n}\n\n/**\n * Wrap the inner content of every `<p …>…</p>` with `<span style=\"…\">…</span>`.\n *\n * Hand-rolled linear scanner instead of `/<p([^>]*)>([\\s\\S]*?)<\\/p>/g` because\n * the regex is polynomial-ReDoS: the engine retries `[\\s\\S]*?<\\/p>` at every\n * `<p` start, so inputs like `<p>a<p>a<p>a…` (no `</p>` ever) cost O(n²).\n * The scanner advances `i` monotonically via `indexOf`, keeping the work\n * strictly O(n).\n */\nfunction wrapParagraphInner(html: string, spanStyle: string): string {\n let out = \"\";\n let i = 0;\n while (i < html.length) {\n const open = html.indexOf(\"<p\", i);\n if (open === -1) {\n out += html.substring(i);\n break;\n }\n const afterTagName = html[open + 2];\n if (\n afterTagName !== \">\" &&\n afterTagName !== \" \" &&\n afterTagName !== \"\\t\" &&\n afterTagName !== \"\\n\" &&\n afterTagName !== \"\\r\" &&\n afterTagName !== \"/\"\n ) {\n out += html.substring(i, open + 2);\n i = open + 2;\n continue;\n }\n const openEnd = html.indexOf(\">\", open + 2);\n if (openEnd === -1) {\n out += html.substring(i);\n break;\n }\n const closeStart = html.indexOf(\"</p>\", openEnd + 1);\n if (closeStart === -1) {\n out += html.substring(i);\n break;\n }\n const inner = html.substring(openEnd + 1, closeStart);\n out += html.substring(i, openEnd + 1);\n out += `<span style=\"${spanStyle}\">${inner}</span></p>`;\n i = closeStart + 4;\n }\n return out;\n}\n\nfunction ensureParagraphWrapped(html: string): string {\n if (!html) return \"<p></p>\";\n if (/<p[\\s>]/i.test(html)) return html;\n return `<p>${html}</p>`;\n}\n\nfunction convertText(values: UnlayerContentValues, textColor: string): Block {\n const html = ensureParagraphWrapped(values.text ?? \"\");\n\n return createParagraphBlock({\n content: inlineStylesToHtml(html, values, textColor),\n styles: makeStyles(values),\n });\n}\n\nfunction parseHeadingLevel(tag: string | undefined): HeadingLevel {\n if (!tag) return 2;\n const match = tag.match(/^h(\\d)$/i);\n if (match) {\n const num = Number(match[1]);\n if (num >= 1 && num <= 4) return num as HeadingLevel;\n }\n return 2;\n}\n\nfunction convertHeading(values: UnlayerContentValues): Block {\n const text = values.text ?? \"\";\n const stripped = text.replace(/^<h\\d[^>]*>|<\\/h\\d>$/gi, \"\");\n const content = stripped ? `<p>${stripped}</p>` : \"<p></p>\";\n\n return createTitleBlock({\n content,\n level: parseHeadingLevel(values.headingType),\n color: parseColor(values.color) || undefined,\n textAlign: toAlign(values.textAlign),\n fontFamily: parseFontFamily(values.fontFamily) || undefined,\n styles: makeStyles(values),\n });\n}\n\nfunction convertImage(values: UnlayerContentValues): Block {\n const src = values.src;\n const action = values.action?.values;\n\n // Kept separate from the `?? 600` fallback below: a percentage radius has to\n // resolve against a width the template actually stated.\n const readWidth = src?.width ? Math.round(src.width) : undefined;\n const readHeight = src?.height ? Math.round(src.height) : undefined;\n\n return createImageBlock({\n src: src?.url || \"\",\n alt: values.altText || \"\",\n width: readWidth ?? 600,\n // No default, unlike width: an absent height keeps the aspect ratio.\n height: readHeight,\n borderRadius: parseImageBorderRadius(\n values.borderRadius,\n readWidth,\n readHeight,\n ),\n align: toAlign(values.textAlign, \"center\"),\n linkUrl: action?.href || undefined,\n linkOpenInNewTab: action?.target === \"_blank\" || undefined,\n styles: makeStyles(values),\n });\n}\n\nfunction convertButton(values: UnlayerContentValues): Block {\n const colors = values.buttonColors ?? {};\n const padding = values.padding\n ? parsePaddingShorthand(values.padding)\n : { top: 12, right: 24, bottom: 12, left: 24 };\n const label = stripTagsPlain(values.text ?? \"Button\");\n const linkValues = values.href?.values;\n\n return createButtonBlock({\n text: label,\n url: linkValues?.href || \"#\",\n openInNewTab: linkValues?.target === \"_blank\" || undefined,\n backgroundColor: parseColor(colors.backgroundColor) || \"#4f46e5\",\n textColor: parseColor(colors.color) || \"#ffffff\",\n borderRadius: parsePxValue(values.borderRadius),\n fontSize: parsePxValue(values.fontSize) || 16,\n fontFamily: parseFontFamily(values.fontFamily) || undefined,\n align: toAlign(values.textAlign, \"center\"),\n buttonPadding: padding,\n styles: makeStyles(values),\n });\n}\n\n/**\n * `\"full\"` when the divider spans its column: no width, `100%`, or a px width\n * that reaches `room`, the span the column leaves the line. Any other\n * percentage stays a percentage, clamped to 0–100%.\n */\nfunction resolveDividerWidth(\n value: string | number | undefined,\n room: number,\n notes: string[],\n): DividerBlock[\"width\"] {\n const raw = String(value ?? \"\").trim();\n if (!raw) return \"full\";\n\n const parsed = parseDividerWidth(typeof value === \"number\" ? value : raw);\n if (!parsed) {\n notes.push(\n `Divider width \"${raw}\" could not be read; imported as full width.`,\n );\n return \"full\";\n }\n\n if (parsed.unit === \"%\") {\n const percent = Math.min(100, Math.max(0, parsed.value));\n if (percent !== parsed.value) {\n notes.push(`Divider width ${raw} was clamped to ${percent}%.`);\n }\n // Two decimals keep the value inside `DividerPercentWidth`'s pattern,\n // which a float printed in exponent form would leave.\n const share = Math.round(percent * 100) / 100;\n return share === 100 ? \"full\" : `${share}%`;\n }\n\n const px = Math.max(0, Math.round(parsed.value));\n if (px !== Math.round(parsed.value)) {\n notes.push(`Divider width ${raw} was clamped to 0px.`);\n }\n return px >= room ? \"full\" : px;\n}\n\n/**\n * Unlayer places a partial divider by `textAlign`, centred by default.\n * Templatical centres every divider, so a left- or right-aligned partial one\n * comes back with a note.\n */\nfunction convertDivider(\n values: UnlayerContentValues,\n columnWidth: number,\n): { block: Block; notes: string[] } {\n const border = parseBorderObject(values.border);\n const styles = makeStyles(values);\n const notes: string[] = [];\n // `mj-divider` draws 100% across the column less the divider's own side\n // padding, so a px width that reaches that span renders as \"full\" does.\n const room = columnWidth - styles.padding.left - styles.padding.right;\n const width = resolveDividerWidth(values.width, room, notes);\n\n const align = values.textAlign;\n if (width !== \"full\" && (align === \"left\" || align === \"right\")) {\n notes.push(\n `Unlayer aligns this divider ${align}; Templatical centres every divider.`,\n );\n }\n\n return {\n block: createDividerBlock({\n lineStyle: toLineStyle(border.style),\n color: border.color,\n thickness: border.width || 1,\n width,\n styles,\n }),\n notes,\n };\n}\n\nfunction convertSpacer(values: UnlayerContentValues): Block {\n const padding = parsePaddingShorthand(values.containerPadding);\n const height =\n parsePxValue((values as { height?: string | number }).height) ||\n padding.top + padding.bottom ||\n 24;\n\n return createSpacerBlock({\n height,\n styles: makeStyles(values),\n });\n}\n\nfunction convertHtml(values: UnlayerContentValues): Block {\n return createHtmlBlock({\n content: values.html ?? \"\",\n styles: makeStyles(values),\n });\n}\n\nfunction convertSocial(\n values: UnlayerContentValues,\n warnings: string[],\n): Block {\n const iconList = values.icons?.icons ?? [];\n const icons: SocialIcon[] = [];\n\n for (const unlayerIcon of iconList) {\n const id = (unlayerIcon.name ?? \"\").toLowerCase();\n const platform = SOCIAL_PLATFORM_MAP[id];\n\n if (!platform) {\n warnings.push(\n `Unrecognized social icon \"${unlayerIcon.name || id}\" was skipped.`,\n );\n continue;\n }\n\n icons.push({\n id: generateId(),\n platform,\n url: unlayerIcon.url || \"#\",\n });\n }\n\n return createSocialIconsBlock({\n icons,\n align: toAlign(values.textAlign, \"center\"),\n styles: makeStyles(values),\n });\n}\n\nfunction convertVideo(values: UnlayerContentValues): Block {\n return createVideoBlock({\n url: values.videoUrl || \"\",\n thumbnailUrl: values.thumbnailUrl || \"\",\n alt: values.altText || \"\",\n width: 600,\n align: toAlign(values.textAlign, \"center\"),\n styles: makeStyles(values),\n });\n}\n\nfunction convertMenu(values: UnlayerContentValues): Block {\n const menu = values.menu;\n const items: MenuItemData[] = (menu?.items ?? []).map((item) => ({\n id: generateId(),\n text: item.text || \"\",\n url: item.link?.values?.href || \"#\",\n openInNewTab: item.link?.values?.target === \"_blank\",\n bold: false,\n underline: false,\n }));\n\n return createMenuBlock({\n items,\n separator: values.separator || \"|\",\n separatorColor: \"#999999\",\n fontSize: parsePxValue(values.fontSize) || 14,\n color: parseColor(values.color) || undefined,\n fontFamily: parseFontFamily(values.fontFamily) || undefined,\n textAlign: toAlign(values.textAlign, \"center\"),\n styles: makeStyles(values),\n });\n}\n\nfunction convertHtmlFallback(content: UnlayerContent, comment: string): Block {\n const safe = comment.replace(/</g, \"<\").replace(/>/g, \">\");\n return createHtmlBlock({\n content: `<div style=\"padding:12px;border:1px dashed #d1d5db;border-radius:6px;background:#fafafa;color:#6b7280;font-family:sans-serif;font-size:13px;\">${safe}</div>`,\n styles: makeStyles(content.values),\n });\n}\n\n/**\n * Converts a single Unlayer content node to a Templatical block.\n * Returns the block and a report entry.\n */\nexport function convertContent(\n content: UnlayerContent,\n warnings: string[],\n context: ContentContext = {},\n): { block: Block; entry: ImportReportEntry } {\n const type = content.type;\n const values = content.values ?? ({} as UnlayerContentValues);\n const columnWidth = context.columnWidth ?? DEFAULT_BODY_WIDTH;\n const textColor = context.textColor ?? FALLBACK_TEXT_COLOR;\n\n switch (type) {\n case \"text\":\n return {\n block: convertText(values, textColor),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"paragraph\",\n status: \"converted\",\n },\n };\n case \"heading\":\n return {\n block: convertHeading(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"title\",\n status: \"converted\",\n },\n };\n case \"image\":\n return {\n block: convertImage(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"image\",\n status: \"converted\",\n },\n };\n case \"button\":\n return {\n block: convertButton(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"button\",\n status: \"converted\",\n },\n };\n case \"divider\": {\n const { block, notes } = convertDivider(values, columnWidth);\n return {\n block,\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"divider\",\n status: notes.length > 0 ? \"approximated\" : \"converted\",\n ...(notes.length > 0 ? { note: notes.join(\" \") } : {}),\n },\n };\n }\n case \"spacer\":\n return {\n block: convertSpacer(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"spacer\",\n status: \"converted\",\n },\n };\n case \"html\":\n return {\n block: convertHtml(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"html\",\n status: \"converted\",\n },\n };\n case \"menu\":\n return {\n block: convertMenu(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"menu\",\n status: \"approximated\",\n note: \"Menu styles map approximately; review spacing and separator color.\",\n },\n };\n case \"social\":\n return {\n block: convertSocial(values, warnings),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"social\",\n status: \"converted\",\n },\n };\n case \"video\":\n return {\n block: convertVideo(values),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"video\",\n status: \"converted\",\n },\n };\n case \"timer\":\n return {\n block: convertHtmlFallback(\n content,\n \"Unlayer timer block: rebuild manually in Templatical\",\n ),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"html\",\n status: \"html-fallback\",\n note: \"Timer modules have no direct Templatical equivalent; placeholder HTML inserted.\",\n },\n };\n case \"form\":\n return {\n block: convertHtmlFallback(\n content,\n \"Unlayer form block: not supported in Templatical (most email clients block form submission)\",\n ),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: null,\n status: \"skipped\",\n note: \"Unlayer forms have no Templatical equivalent and are skipped. Most email clients block form submission anyway.\",\n },\n };\n default:\n return {\n block: convertHtmlFallback(\n content,\n `Unsupported Unlayer content type: ${type}`,\n ),\n entry: {\n unlayerContentType: type,\n templaticalBlockType: \"html\",\n status: \"html-fallback\",\n note: `Unknown content type \"${type}\" converted to HTML block.`,\n },\n };\n }\n}\n","import {\n createSectionBlock,\n createDefaultTemplateContent,\n} from \"@templatical/types\";\nimport type { Block, ColumnLayout, TemplateContent } from \"@templatical/types\";\nimport type {\n UnlayerTemplate,\n UnlayerRow,\n UnlayerColumn,\n ImportResult,\n ImportReport,\n ImportReportEntry,\n} from \"./types\";\nimport {\n convertContent,\n DEFAULT_BODY_WIDTH,\n FALLBACK_TEXT_COLOR,\n} from \"./block-mapper\";\nimport type { ContentContext } from \"./block-mapper\";\nimport {\n parsePxValue,\n parseColor,\n parseFontFamily,\n parsePaddingShorthand,\n} from \"./style-parser\";\n\nfunction resolveColumnLayout(\n cells: number[],\n warnings: string[],\n): ColumnLayout {\n if (cells.length <= 1) return \"1\";\n if (cells.length === 3) return \"3\";\n\n if (cells.length === 2) {\n const left = cells[0] ?? 1;\n const right = cells[1] ?? 1;\n const total = left + right;\n const ratio = left / total;\n\n if (ratio > 0.58) return \"2-1\";\n if (ratio < 0.42) return \"1-2\";\n return \"2\";\n }\n\n warnings.push(\n `Row with ${cells.length} columns was flattened to a single column. Unlayer supports arbitrary columns, but Templatical supports up to 3.`,\n );\n return \"1\";\n}\n\n/** Each column's share of the body width, by layout. */\nconst COLUMN_SHARES: Record<ColumnLayout, number[]> = {\n \"1\": [1],\n \"2\": [1 / 2, 1 / 2],\n \"3\": [1 / 3, 1 / 3, 1 / 3],\n \"1-2\": [1 / 3, 2 / 3],\n \"2-1\": [2 / 3, 1 / 3],\n};\n\n/**\n * A column's px width as the renderer draws it: the body width times the\n * column's share, rounded down. A column past the layout's last slot takes\n * the whole body width, the renderer's fallback.\n */\nfunction columnWidthAt(\n layout: ColumnLayout,\n bodyWidth: number,\n index: number,\n): number {\n return Math.floor(bodyWidth * (COLUMN_SHARES[layout][index] ?? 1));\n}\n\n/**\n * Converts all contents in a column to Templatical blocks.\n */\nfunction convertColumnContents(\n column: UnlayerColumn,\n context: ContentContext,\n entries: ImportReportEntry[],\n warnings: string[],\n): Block[] {\n const blocks: Block[] = [];\n\n for (const content of column.contents ?? []) {\n const { block, entry } = convertContent(content, warnings, context);\n blocks.push(block);\n entries.push(entry);\n }\n\n return blocks;\n}\n\n/**\n * The section's fill. `columnsBackgroundColor` covers the content width, the\n * area a section paints; `backgroundColor` is the band outside it, used only\n * when the row sets no content colour.\n */\nfunction resolveRowBackground(\n row: UnlayerRow,\n warnings: string[],\n): string | undefined {\n const content = parseColor(row.values?.columnsBackgroundColor);\n const band = parseColor(row.values?.backgroundColor);\n if (content && band && content !== band) {\n warnings.push(\n `Row background ${band} outside the content width was dropped; the section keeps the content background ${content}.`,\n );\n }\n return content || band || undefined;\n}\n\n/**\n * Processes a single Unlayer row into one or more Templatical blocks.\n *\n * Each column's px width derives from `settings.width` and the resolved\n * layout; every block also learns the template's `textColor`.\n */\nfunction processRow(\n row: UnlayerRow,\n settings: TemplateContent[\"settings\"],\n entries: ImportReportEntry[],\n warnings: string[],\n): Block[] {\n const columns = row.columns;\n if (!columns || columns.length === 0) return [];\n\n const cells = row.cells ?? columns.map(() => 1);\n const layout = resolveColumnLayout(cells, warnings);\n const contextAt = (index: number): ContentContext => ({\n columnWidth: columnWidthAt(layout, settings.width, index),\n textColor: settings.textColor,\n });\n\n let children: Block[][];\n if (layout === \"1\") {\n const merged: Block[] = [];\n for (const column of columns) {\n merged.push(\n ...convertColumnContents(column, contextAt(0), entries, warnings),\n );\n }\n children = [merged];\n } else {\n children = columns.map((col, index) =>\n convertColumnContents(col, contextAt(index), entries, warnings),\n );\n }\n\n const background = resolveRowBackground(row, warnings);\n const padding = parsePaddingShorthand(row.values?.padding);\n\n const section = createSectionBlock({\n columns: layout,\n children,\n styles: {\n padding,\n ...(background ? { backgroundColor: background } : {}),\n },\n });\n\n return [section];\n}\n\n/**\n * Extracts template-level settings from the Unlayer body values.\n */\nfunction extractSettings(\n template: UnlayerTemplate,\n): TemplateContent[\"settings\"] {\n const values = template.body?.values ?? {};\n\n const width = parsePxValue(values.contentWidth);\n const bgColor = parseColor(values.backgroundColor) || \"#ffffff\";\n const fontFamily = parseFontFamily(values.fontFamily) || \"Arial\";\n const textColor = parseColor(values.textColor) || FALLBACK_TEXT_COLOR;\n const linkColor = parseColor(values.linkStyle?.linkColor);\n // An unstated underline is on: Unlayer's default, the browser's and the SDK's.\n const underline = values.linkStyle?.linkUnderline;\n const linkUnderline = typeof underline === \"boolean\" ? underline : true;\n const preheaderText =\n typeof values.preheaderText === \"string\" ? values.preheaderText.trim() : \"\";\n\n return {\n width: width > 0 ? width : DEFAULT_BODY_WIDTH,\n backgroundColor: bgColor,\n textColor,\n linkUnderline,\n fontFamily,\n locale: \"en\",\n ...(linkColor ? { linkColor } : {}),\n ...(preheaderText ? { preheaderText } : {}),\n };\n}\n\n/**\n * Converts an Unlayer design JSON to Templatical TemplateContent.\n *\n * @param template - The parsed Unlayer JSON object (the result of `editor.saveDesign(...)`)\n * @returns An ImportResult with the converted content and a detailed report\n *\n * @example\n * ```ts\n * import { convertUnlayerTemplate } from '@templatical/import-unlayer';\n *\n * const unlayerJson = JSON.parse(fileContent);\n * const { content, report } = convertUnlayerTemplate(unlayerJson);\n *\n * const editor = init({ container: '#editor', content });\n *\n * console.log(report.summary);\n * console.log(report.warnings);\n * ```\n */\nexport function convertUnlayerTemplate(\n template: UnlayerTemplate,\n): ImportResult {\n if (!template?.body?.rows) {\n throw new Error(\n \"Invalid Unlayer template: missing body.rows. Ensure you are passing a valid Unlayer JSON design (the output of editor.saveDesign).\",\n );\n }\n\n const entries: ImportReportEntry[] = [];\n const warnings: string[] = [];\n const blocks: Block[] = [];\n\n const headers = template.body.headers ?? [];\n const footers = template.body.footers ?? [];\n const settings = extractSettings(template);\n\n if (headers.length > 0) {\n warnings.push(\n `${headers.length} Unlayer header row(s) were imported as regular rows at the top of the template.`,\n );\n for (const row of headers) {\n blocks.push(...processRow(row, settings, entries, warnings));\n }\n }\n\n for (const row of template.body.rows) {\n blocks.push(...processRow(row, settings, entries, warnings));\n }\n\n if (footers.length > 0) {\n warnings.push(\n `${footers.length} Unlayer footer row(s) were imported as regular rows at the bottom of the template.`,\n );\n for (const row of footers) {\n blocks.push(...processRow(row, settings, entries, warnings));\n }\n }\n\n const content: TemplateContent = {\n ...createDefaultTemplateContent(),\n blocks,\n settings,\n };\n\n const summary = {\n total: entries.length,\n converted: entries.filter((e) => e.status === \"converted\").length,\n approximated: entries.filter((e) => e.status === \"approximated\").length,\n htmlFallback: entries.filter((e) => e.status === \"html-fallback\").length,\n skipped: entries.filter((e) => e.status === \"skipped\").length,\n };\n\n const report: ImportReport = { entries, warnings, summary };\n\n return { content, report };\n}\n"],"mappings":";;;;;AAOA,SAAgB,aAAa,OAA4C;CACvE,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,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AAQ,SAAS,GAAG;EACtB,SAAS,KACP,GAAG,QAAQ,OAAO,iFACpB;EACA,KAAK,MAAM,OAAO,SAChB,OAAO,KAAK,GAAG,WAAW,KAAK,UAAU,SAAS,QAAQ,CAAC;CAE/D;CAEA,KAAK,MAAM,OAAO,SAAS,KAAK,MAC9B,OAAO,KAAK,GAAG,WAAW,KAAK,UAAU,SAAS,QAAQ,CAAC;CAG7D,IAAI,QAAQ,SAAS,GAAG;EACtB,SAAS,KACP,GAAG,QAAQ,OAAO,oFACpB;EACA,KAAK,MAAM,OAAO,SAChB,OAAO,KAAK,GAAG,WAAW,KAAK,UAAU,SAAS,QAAQ,CAAC;CAE/D;CAkBA,OAAO;EAAE,SAAA;GAfP,GAAG,6BAA6B;GAChC;GACA;EAaa;EAAG,QAAA;GAFa;GAAS;GAAU,SAAA;IAPhD,OAAO,QAAQ;IACf,WAAW,QAAQ,QAAQ,MAAM,EAAE,WAAW,WAAW,CAAC,CAAC;IAC3D,cAAc,QAAQ,QAAQ,MAAM,EAAE,WAAW,cAAc,CAAC,CAAC;IACjE,cAAc,QAAQ,QAAQ,MAAM,EAAE,WAAW,eAAe,CAAC,CAAC;IAClE,SAAS,QAAQ,QAAQ,MAAM,EAAE,WAAW,SAAS,CAAC,CAAC;GAGD;EAEjC;CAAE;AAC3B"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@templatical/import-unlayer",
|
|
3
3
|
"description": "Convert Unlayer email templates to Templatical format",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.43.0",
|
|
5
5
|
"bugs": "https://github.com/templatical/sdk/issues",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@templatical/types": "0.
|
|
7
|
+
"@templatical/types": "0.43.0"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"typescript": "^6.0.3",
|