background page
This commit is contained in:
+2
-17
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,7 +513,19 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
||||
zIndex: 1,
|
||||
}}
|
||||
>
|
||||
{page.elements.map((element, index) => renderObject(element, index))}
|
||||
<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>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user