import { getColumnClasses } from '@components/common/form/editor/GetColumnClasses.js'; import { getRowClasses } from '@components/common/form/editor/GetRowClasses.js'; import { Row } from '@components/common/form/Editor.js'; import { Image as ResponsiveImage } from '@components/common/Image.js'; import React from 'react'; import './Editor.scss'; const Paragraph: React.FC<{ data: { text: string } }> = ({ data }) => { return
; }; const Header: React.FC<{ data: { level: number; text: string } }> = ({ data }) => { const tagName = `h${data.level}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; return React.createElement(tagName, null, data.text); }; const List: React.FC<{ data: { items: string[]; style: 'ordered' | 'unordered' }; }> = ({ data }) => { const ListTag = data.style === 'ordered' ? 'ol' : 'ul'; return (); }; const Image: React.FC<{ data: { file: { url: string; width?: number; height?: number }; caption?: string; withBorder?: boolean; withBackground?: boolean; stretched?: boolean; link?: string; }; columnSize: number; }> = ({ data, columnSize }) => { const { file, caption, withBorder, withBackground, stretched, link } = data; const imageStyles = { border: withBorder ? '1px solid #ccc' : 'none', backgroundColor: withBackground ? '#f9f9f9' : 'transparent', width: stretched ? '100%' : 'auto', display: 'block', maxWidth: '100%', margin: '0 auto' }; const imageWidth = file.width || 800; const imageHeight = file.height || (file.width ? Math.round(file.width * 0.75) : 600); // Calculate responsive sizes based on the columnSize prop // columnSize represents the fraction of the row that this column occupies (e.g., 1/2, 1/3, 2/3, etc.) let sizesValue: string; sizesValue = '100vw'; // On mobile, always full viewport width if (columnSize <= 0.25) { sizesValue = '(max-width: 640px) 100vw, (max-width: 768px) 80vw, 25vw'; } else if (columnSize <= 0.34) { sizesValue = '(max-width: 640px) 100vw, (max-width: 768px) 80vw, 33vw'; } else if (columnSize <= 0.5) { sizesValue = '(max-width: 640px) 100vw, (max-width: 768px) 80vw, 50vw'; } else if (columnSize <= 0.67) { sizesValue = '(max-width: 640px) 100vw, (max-width: 768px) 80vw, 67vw'; } else if (columnSize <= 0.75) { sizesValue = '(max-width: 640px) 100vw, (max-width: 768px) 80vw, 75vw'; } else { sizesValue = '(max-width: 640px) 100vw, 100vw'; } const responsiveSizes = sizesValue; const imageElement = ("{data.text}"
{data.caption && - {data.caption}}
{caption}
)}; case 'raw': return