diff --git a/src/pages/viewer/components/BookPage.tsx b/src/pages/viewer/components/BookPage.tsx index b6cdf95..98900ce 100644 --- a/src/pages/viewer/components/BookPage.tsx +++ b/src/pages/viewer/components/BookPage.tsx @@ -21,7 +21,7 @@ type BookPageProps = { * نیاز به forwardRef دارد تا react-pageflip بتواند ref را مدیریت کند */ const BookPage = forwardRef( - ({ page, scale = 1, pageWidth, pageHeight, onLinkClick, backgroundType = 'color', backgroundColor = '#ffffff', backgroundImageUrl = '' }, ref) => { + ({ page, scale = 1, pageWidth, pageHeight, onLinkClick, backgroundType, backgroundColor, backgroundImageUrl }, ref) => { // تابع برای تبدیل opacity به رنگ (مثل editor) // در editor، getColorWithOpacity انتظار opacity 0-100 دارد // در dataTransformer، opacity از 0-1 به 0-100 تبدیل شده است @@ -487,15 +487,19 @@ const BookPage = forwardRef( const width = pageWidth ?? 794 * scale; const height = pageHeight ?? 1123 * scale; + const effectiveBackgroundType = backgroundType ?? page.backgroundType ?? 'color'; + const effectiveBackgroundColor = backgroundColor ?? page.backgroundColor ?? '#ffffff'; + const effectiveBackgroundImageUrl = backgroundImageUrl ?? page.backgroundImageUrl ?? ''; + const bgStyle: React.CSSProperties = - backgroundType === 'image' && backgroundImageUrl + effectiveBackgroundType === 'image' && effectiveBackgroundImageUrl ? { - backgroundImage: `url(${backgroundImageUrl})`, + backgroundImage: `url(${effectiveBackgroundImageUrl})`, backgroundSize: 'cover', backgroundPosition: 'center', backgroundRepeat: 'no-repeat', } - : { backgroundColor: backgroundColor || '#ffffff' }; + : { backgroundColor: effectiveBackgroundColor }; return (