scale viewer

This commit is contained in:
hamid zarghami
2026-03-14 11:42:10 +03:30
parent b5a454a3fe
commit 27f57084e9
7 changed files with 82 additions and 31 deletions
+9 -3
View File
@@ -5,6 +5,8 @@ import type { EditorObject } from '@/pages/editor/store/editorStore';
type BookPageProps = {
page: PageData;
scale?: number;
pageWidth?: number;
pageHeight?: number;
onLinkClick?: (linkUrl: string) => void;
};
@@ -15,7 +17,8 @@ type BookPageProps = {
* این کامپوننت به عنوان child برای HTMLFlipBook استفاده می‌شود
* نیاز به forwardRef دارد تا react-pageflip بتواند ref را مدیریت کند
*/
const BookPage = forwardRef<HTMLDivElement, BookPageProps>(({ page, scale = 1, onLinkClick }, ref) => {
const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
({ page, scale = 1, pageWidth, pageHeight, onLinkClick }, ref) => {
// تابع برای تبدیل opacity به رنگ (مثل editor)
// در editor، getColorWithOpacity انتظار opacity 0-100 دارد
// در dataTransformer، opacity از 0-1 به 0-100 تبدیل شده است
@@ -462,6 +465,9 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(({ page, scale = 1, o
}
};
const width = pageWidth ?? 794 * scale;
const height = pageHeight ?? 1123 * scale;
return (
<div
ref={ref}
@@ -472,8 +478,8 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(({ page, scale = 1, o
backgroundColor: '#ffffff',
overflow: 'hidden',
boxSizing: 'border-box',
width: `${794 * scale}px`,
height: `${1123 * scale}px`,
width: `${width}px`,
height: `${height}px`,
isolation: 'isolate',
zIndex: 1,
}}