background page

This commit is contained in:
hamid zarghami
2026-05-06 15:25:26 +03:30
parent 25822b05a6
commit f42fc17025
6 changed files with 42 additions and 24 deletions
+2 -17
View File
@@ -90,23 +90,7 @@ html {
filter: brightness(0) invert(0);
}
/* استایل برای صفحات کتاب - بکگراند سفید */
.stf__item.page,
.stf__item[class*="page"],
.page.stf__item,
div.stf__item.page,
.stf__block .stf__item,
.stf__parent .stf__item,
.stf__wrapper .stf__item {
background-color: #ffffff !important;
background: #ffffff !important;
}
/* برای اطمینان بیشتر - تمام صفحات با کلاس page */
.page {
background-color: #ffffff !important;
background: #ffffff !important;
}
/* رنگ پس‌زمینه باید از خود BookPage بیاید (per-page). */
/* استایل برای ظاهر کتاب */
.flipbook-container {
@@ -139,6 +123,7 @@ div.stf__item.page,
border-radius: 0;
}
/* جلوگیری از نمایش محتوای صفحات غیرفعال هنگام هاور */
.flipbook-container .stf__item {
overflow: hidden !important;
+15 -2
View File
@@ -35,6 +35,7 @@ export const useUpdateCatalog = () => {
});
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const pendingParamsRef = useRef<Parameters<typeof api.updateCatalog>[0] | null>(null);
const [isScheduledSaving, setIsScheduledSaving] = useState(false);
const scheduleUpdate = useCallback(
@@ -42,12 +43,17 @@ export const useUpdateCatalog = () => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
pendingParamsRef.current = params;
setIsScheduledSaving(true);
timeoutRef.current = setTimeout(() => {
const pendingParams = pendingParamsRef.current;
timeoutRef.current = null;
pendingParamsRef.current = null;
setIsScheduledSaving(false);
mutation.mutate(params);
if (pendingParams) {
mutation.mutate(pendingParams);
}
}, delayMs);
},
[mutation],
@@ -57,10 +63,17 @@ export const useUpdateCatalog = () => {
() => () => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
timeoutRef.current = null;
}
// اگر کاربر قبل از پایان debounce از ادیتور خارج شد،
// آخرین تغییرات معلق را همان لحظه ذخیره کن.
if (pendingParamsRef.current) {
mutation.mutate(pendingParamsRef.current);
pendingParamsRef.current = null;
}
setIsScheduledSaving(false);
},
[],
[mutation],
);
return {
+12 -1
View File
@@ -505,7 +505,6 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
data-density="soft"
style={{
position: 'relative',
...bgStyle,
overflow: 'hidden',
boxSizing: 'border-box',
width: `${width}px`,
@@ -514,8 +513,20 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
zIndex: 1,
}}
>
<div
aria-hidden
style={{
position: 'absolute',
inset: 0,
...bgStyle,
pointerEvents: 'none',
zIndex: 0,
}}
/>
<div style={{ position: 'absolute', inset: 0, zIndex: 1 }}>
{page.elements.map((element, index) => renderObject(element, index))}
</div>
</div>
);
});
+3 -3
View File
@@ -456,9 +456,9 @@ const BookViewer: FC<BookViewerProps> = ({ pages, catalogSize, documentSettings
pageWidth={pagePixelWidth}
pageHeight={pagePixelHeight}
onLinkClick={handleLinkClick}
backgroundType={backgroundType}
backgroundColor={backgroundColor}
backgroundImageUrl={backgroundImageUrl}
backgroundType={page.backgroundType ?? backgroundType}
backgroundColor={page.backgroundColor ?? backgroundColor}
backgroundImageUrl={page.backgroundImageUrl ?? backgroundImageUrl}
/>
))}
</HTMLFlipBook>
+3
View File
@@ -5,5 +5,8 @@ export type PageData = {
width: number;
height: number;
elements: EditorObject[];
backgroundType?: "color" | "image";
backgroundColor?: string;
backgroundImageUrl?: string;
};
@@ -4,6 +4,9 @@ import type { PageData } from "../types";
type ViewerDataPage = {
id: string;
name: string;
backgroundType?: "color" | "image";
backgroundColor?: string;
backgroundImageUrl?: string;
objects: Array<{
id: string;
type: string;
@@ -126,6 +129,9 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
width: 794,
height: 1123,
elements: objects,
backgroundType: page.backgroundType,
backgroundColor: page.backgroundColor,
backgroundImageUrl: page.backgroundImageUrl,
};
});
}