- | {
+ if (!border || border.style === "none") {
+ return "";
+ }
+
+ const {
+ width = "0px",
+ color = "#E5E7EB",
+ style = "solid",
+ sides = [],
+ } = border;
+
+ // اگر width صفر باشد یا تعریف نشده باشد، border نمایش نده
+ if (!width || width === "0px") {
+ return "";
+ }
+
+ if (sides.length === 0 || sides.length === 4) {
+ return `border: ${width} ${style} ${color};`;
+ }
+
+ // Generate individual border sides
+ const borderStyles: string[] = [];
+ sides.forEach((side) => {
+ borderStyles.push(`border-${side}: ${width} ${style} ${color}`);
+ });
+
+ return borderStyles.join("; ") + ";";
+ };
+
// Render section equivalent (HeaderSection, ContentSection, FooterSection)
const renderSection = (
section: SectionType & { name?: string; isContent?: boolean },
- sectionHeight: string,
- paddingTop = ""
+ sectionHeight: string
) => {
console.log(`🔥 [ExportHTML] Rendering section:`, {
columnsCount: section.columnsCount,
@@ -381,13 +433,21 @@ export const exportPersonalityToHTML = async (
});
if (section.columnsCount > 0) {
- return ` |
- ${paddingTop ? `| ` : " | "}
-
+ return `
+
+
-
-
+
+
${Array.from(
@@ -432,7 +492,9 @@ export const exportPersonalityToHTML = async (
};`
: ""
} padding: 0; vertical-align: top; border-radius: 8px; position: relative;">
-
+
`;
// اگر محتوایی وجود دارد (متن، دکمه، تصویر، یا شبکه اجتماعی)
@@ -449,7 +511,11 @@ export const exportPersonalityToHTML = async (
item.buttons[0]
)}" valign="${getButtonVerticalAlign(
item.buttons[0]
- )}" style="padding: 8px;">
+ )}" style="padding: 8px; text-align: ${getButtonHorizontalAlign(
+ item.buttons[0]
+ )}; vertical-align: ${getButtonVerticalAlign(
+ item.buttons[0]
+ )}; ${generateBorderStyle(section.border)}">
${renderImages(item?.images || [])}
${renderSocials(item?.socials || [])}
${
@@ -475,8 +541,22 @@ export const exportPersonalityToHTML = async (
30
).toString();
+ const textAlignment = hasTexts
+ ? getTextAlignment(item.texts[0]?.alignment)
+ : "center";
+ const textVerticalAlignment =
+ hasTexts && item.texts[0]?.verticalAlignment
+ ? item.texts[0].verticalAlignment === "top"
+ ? "top"
+ : item.texts[0].verticalAlignment ===
+ "bottom"
+ ? "bottom"
+ : "middle"
+ : "middle";
result += `
- |
+ |
${renderTexts(item?.texts || [])}
${renderImages(item?.images || [])}
${renderSocials(item?.socials || [])}
@@ -498,7 +578,11 @@ export const exportPersonalityToHTML = async (
item.buttons[0]
)}" valign="${getButtonVerticalAlign(
item.buttons[0]
- )}" style="padding: 0 8px 8px 8px;">
+ )}" style="padding: 0 8px 8px 8px; text-align: ${getButtonHorizontalAlign(
+ item.buttons[0]
+ )}; vertical-align: ${getButtonVerticalAlign(
+ item.buttons[0]
+ )}; ${generateBorderStyle(section.border)}">
${renderButtons(item.buttons)}
|
`;
@@ -522,7 +606,9 @@ export const exportPersonalityToHTML = async (
30
);
result += `
- |
+ |
{{content}}
|
`;
@@ -570,13 +656,17 @@ export const exportPersonalityToHTML = async (
? Math.max(sectionHeightNumber + 40, 286)
: sectionHeight;
- return `
- ${paddingTop ? `| ` : " | "}
-
+ return `
+
+
-
-
+
+
${emptyMessage}
|
@@ -639,8 +729,8 @@ export const exportPersonalityToHTML = async (
isContent: sectionData.isContent,
});
- // Pass the complete section data for rendering
- const renderedSection = renderSection(sectionData, height, "");
+ // Pass the complete section data for rendering with no spacing
+ const renderedSection = renderSection(sectionData, height);
console.log(
`🔥 [ExportHTML] Section ${sectionKey} rendered, HTML length:`,
renderedSection.length
@@ -660,7 +750,7 @@ export const exportPersonalityToHTML = async (
);
const html = ` | | | | | | |