background page
This commit is contained in:
+2
-17
@@ -90,23 +90,7 @@ html {
|
|||||||
filter: brightness(0) invert(0);
|
filter: brightness(0) invert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* استایل برای صفحات کتاب - بکگراند سفید */
|
/* رنگ پسزمینه باید از خود BookPage بیاید (per-page). */
|
||||||
.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* استایل برای ظاهر کتاب */
|
/* استایل برای ظاهر کتاب */
|
||||||
.flipbook-container {
|
.flipbook-container {
|
||||||
@@ -139,6 +123,7 @@ div.stf__item.page,
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* جلوگیری از نمایش محتوای صفحات غیرفعال هنگام هاور */
|
/* جلوگیری از نمایش محتوای صفحات غیرفعال هنگام هاور */
|
||||||
.flipbook-container .stf__item {
|
.flipbook-container .stf__item {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export const useUpdateCatalog = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
const pendingParamsRef = useRef<Parameters<typeof api.updateCatalog>[0] | null>(null);
|
||||||
const [isScheduledSaving, setIsScheduledSaving] = useState(false);
|
const [isScheduledSaving, setIsScheduledSaving] = useState(false);
|
||||||
|
|
||||||
const scheduleUpdate = useCallback(
|
const scheduleUpdate = useCallback(
|
||||||
@@ -42,12 +43,17 @@ export const useUpdateCatalog = () => {
|
|||||||
if (timeoutRef.current) {
|
if (timeoutRef.current) {
|
||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
}
|
}
|
||||||
|
pendingParamsRef.current = params;
|
||||||
setIsScheduledSaving(true);
|
setIsScheduledSaving(true);
|
||||||
|
|
||||||
timeoutRef.current = setTimeout(() => {
|
timeoutRef.current = setTimeout(() => {
|
||||||
|
const pendingParams = pendingParamsRef.current;
|
||||||
timeoutRef.current = null;
|
timeoutRef.current = null;
|
||||||
|
pendingParamsRef.current = null;
|
||||||
setIsScheduledSaving(false);
|
setIsScheduledSaving(false);
|
||||||
mutation.mutate(params);
|
if (pendingParams) {
|
||||||
|
mutation.mutate(pendingParams);
|
||||||
|
}
|
||||||
}, delayMs);
|
}, delayMs);
|
||||||
},
|
},
|
||||||
[mutation],
|
[mutation],
|
||||||
@@ -57,10 +63,17 @@ export const useUpdateCatalog = () => {
|
|||||||
() => () => {
|
() => () => {
|
||||||
if (timeoutRef.current) {
|
if (timeoutRef.current) {
|
||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
|
timeoutRef.current = null;
|
||||||
|
}
|
||||||
|
// اگر کاربر قبل از پایان debounce از ادیتور خارج شد،
|
||||||
|
// آخرین تغییرات معلق را همان لحظه ذخیره کن.
|
||||||
|
if (pendingParamsRef.current) {
|
||||||
|
mutation.mutate(pendingParamsRef.current);
|
||||||
|
pendingParamsRef.current = null;
|
||||||
}
|
}
|
||||||
setIsScheduledSaving(false);
|
setIsScheduledSaving(false);
|
||||||
},
|
},
|
||||||
[],
|
[mutation],
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -505,7 +505,6 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
|||||||
data-density="soft"
|
data-density="soft"
|
||||||
style={{
|
style={{
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
...bgStyle,
|
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
boxSizing: 'border-box',
|
boxSizing: 'border-box',
|
||||||
width: `${width}px`,
|
width: `${width}px`,
|
||||||
@@ -514,7 +513,19 @@ const BookPage = forwardRef<HTMLDivElement, BookPageProps>(
|
|||||||
zIndex: 1,
|
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>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -456,9 +456,9 @@ const BookViewer: FC<BookViewerProps> = ({ pages, catalogSize, documentSettings
|
|||||||
pageWidth={pagePixelWidth}
|
pageWidth={pagePixelWidth}
|
||||||
pageHeight={pagePixelHeight}
|
pageHeight={pagePixelHeight}
|
||||||
onLinkClick={handleLinkClick}
|
onLinkClick={handleLinkClick}
|
||||||
backgroundType={backgroundType}
|
backgroundType={page.backgroundType ?? backgroundType}
|
||||||
backgroundColor={backgroundColor}
|
backgroundColor={page.backgroundColor ?? backgroundColor}
|
||||||
backgroundImageUrl={backgroundImageUrl}
|
backgroundImageUrl={page.backgroundImageUrl ?? backgroundImageUrl}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</HTMLFlipBook>
|
</HTMLFlipBook>
|
||||||
|
|||||||
@@ -5,5 +5,8 @@ export type PageData = {
|
|||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
elements: EditorObject[];
|
elements: EditorObject[];
|
||||||
|
backgroundType?: "color" | "image";
|
||||||
|
backgroundColor?: string;
|
||||||
|
backgroundImageUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import type { PageData } from "../types";
|
|||||||
type ViewerDataPage = {
|
type ViewerDataPage = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
backgroundType?: "color" | "image";
|
||||||
|
backgroundColor?: string;
|
||||||
|
backgroundImageUrl?: string;
|
||||||
objects: Array<{
|
objects: Array<{
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -126,6 +129,9 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
|
|||||||
width: 794,
|
width: 794,
|
||||||
height: 1123,
|
height: 1123,
|
||||||
elements: objects,
|
elements: objects,
|
||||||
|
backgroundType: page.backgroundType,
|
||||||
|
backgroundColor: page.backgroundColor,
|
||||||
|
backgroundImageUrl: page.backgroundImageUrl,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user