This commit is contained in:
Tomas Dvorak
2025-05-29 10:52:15 +02:00
parent f50b64f876
commit 6f03f65e29
+41 -31
View File
@@ -153,40 +153,50 @@
</a>`; </a>`;
} }
// Add image to content based on position // Add content based on image position
if (['left', 'top'].includes(imagePosition)) { if (imagePosition === 'left' || imagePosition === 'right') {
content += imgContainer; // For side-by-side layout
}
// Add text content with proper spacing
if (bannerText) {
const textStyle = `
margin: 0;
padding: 10px;
line-height: 1.6;
color: ${textColor};
text-align: ${textAlign};
font-size: ${fontSize};
${['left', 'right'].includes(imagePosition) ? 'overflow: hidden;' : 'display: block;'}
${imagePosition === 'left' ? 'padding-left: 20px;' : ''}
${imagePosition === 'right' ? 'padding-right: 20px;' : ''}
`;
// Wrap text in link if URL is provided
const textContent = bannerText.replace(/\n/g, '<br>');
const textElement = bannerLink
? `<a href="${bannerLink}" target="_blank" style="color: inherit; text-decoration: none;">${textContent}</a>`
: textContent;
content += ` content += `
<div class="banner-text" style="${textStyle}"> <div style="display: flex; flex-direction: ${imagePosition === 'left' ? 'row' : 'row-reverse'}; align-items: center; gap: 20px;">
${textElement} ${imgContainer}
<div style="flex: 1;">
<div class="banner-text" style="
margin: 0;
padding: 10px;
line-height: 1.6;
color: ${textColor};
text-align: ${textAlign};
font-size: ${fontSize};
">
${bannerLink ? `<a href="${bannerLink}" target="_blank" style="color: inherit; text-decoration: none;">${bannerText.replace(/\n/g, '<br>')}</a>` : bannerText.replace(/\n/g, '<br>')}
</div>
</div>
</div>`; </div>`;
} } else {
// For top/bottom layout
if (imagePosition === 'top' || imagePosition === 'bottom') {
content += imgContainer;
}
// Add image if position is right or bottom (only if not already added) // Add text
if (['right', 'bottom'].includes(imagePosition) && !['left', 'top'].includes(imagePosition)) { if (bannerText) {
content += imgContainer; content += `
<div class="banner-text" style="
margin: 0;
padding: 10px;
line-height: 1.6;
color: ${textColor};
text-align: ${textAlign};
font-size: ${fontSize};
display: block;
">
${bannerLink ? `<a href="${bannerLink}" target="_blank" style="color: inherit; text-decoration: none;">${bannerText.replace(/\n/g, '<br>')}</a>` : bannerText.replace(/\n/g, '<br>')}
</div>`;
}
if (imagePosition === 'bottom') {
content += imgContainer;
}
} }
// Add clearfix if needed // Add clearfix if needed