(
}}
>
{!useHardPage && (
-
+ <>
+
+ {effectiveBackgroundType === 'video' && effectiveBackgroundVideoUrl && (
+
+ )}
+ >
)}
{page.elements.map((element, index) => renderObject(element, index, page.elements))}
diff --git a/src/pages/viewer/components/BookViewer.tsx b/src/pages/viewer/components/BookViewer.tsx
index b1b8164..9ca119d 100644
--- a/src/pages/viewer/components/BookViewer.tsx
+++ b/src/pages/viewer/components/BookViewer.tsx
@@ -185,9 +185,10 @@ const BookViewer: FC = ({ pages, catalogSize, documentSettings
const backgroundColor = documentSettings?.backgroundColor ?? "#ffffff";
const backgroundGradient = documentSettings?.backgroundGradient;
const backgroundImageUrl = documentSettings?.backgroundImageUrl ?? "";
+ const backgroundVideoUrl = documentSettings?.backgroundVideoUrl ?? "";
const pageBackgroundDefaults = useMemo(
- () => ({ backgroundType, backgroundColor, backgroundGradient, backgroundImageUrl }),
- [backgroundType, backgroundColor, backgroundGradient, backgroundImageUrl],
+ () => ({ backgroundType, backgroundColor, backgroundGradient, backgroundImageUrl, backgroundVideoUrl }),
+ [backgroundType, backgroundColor, backgroundGradient, backgroundImageUrl, backgroundVideoUrl],
);
useEffect(() => {
@@ -610,6 +611,7 @@ const BookViewer: FC = ({ pages, catalogSize, documentSettings
backgroundColor={background.backgroundColor}
backgroundGradient={background.backgroundGradient}
backgroundImageUrl={background.backgroundImageUrl}
+ backgroundVideoUrl={background.backgroundVideoUrl}
useHardPage={legacyIOS}
/>
);
diff --git a/src/pages/viewer/components/Magnifier/Magnifier.tsx b/src/pages/viewer/components/Magnifier/Magnifier.tsx
index 002f925..47bae99 100644
--- a/src/pages/viewer/components/Magnifier/Magnifier.tsx
+++ b/src/pages/viewer/components/Magnifier/Magnifier.tsx
@@ -94,6 +94,7 @@ const Magnifier = memo(
backgroundColor={background.backgroundColor}
backgroundGradient={background.backgroundGradient}
backgroundImageUrl={background.backgroundImageUrl}
+ backgroundVideoUrl={background.backgroundVideoUrl}
useHardPage={useHardPage}
disableEntranceAnimations
showPaperShadow={false}
diff --git a/src/pages/viewer/types/index.ts b/src/pages/viewer/types/index.ts
index 7b3409c..7f267e4 100644
--- a/src/pages/viewer/types/index.ts
+++ b/src/pages/viewer/types/index.ts
@@ -5,7 +5,7 @@ export type PageData = {
width: number;
height: number;
elements: EditorObject[];
- backgroundType?: "color" | "gradient" | "image";
+ backgroundType?: "color" | "gradient" | "image" | "video";
backgroundColor?: string;
backgroundGradient?: {
from: string;
@@ -13,5 +13,6 @@ export type PageData = {
angle: number;
};
backgroundImageUrl?: string;
+ backgroundVideoUrl?: string;
};
diff --git a/src/pages/viewer/utils/dataTransformer.ts b/src/pages/viewer/utils/dataTransformer.ts
index c74f8ab..7d932ca 100644
--- a/src/pages/viewer/utils/dataTransformer.ts
+++ b/src/pages/viewer/utils/dataTransformer.ts
@@ -5,7 +5,7 @@ import type { PageData } from "../types";
type ViewerDataPage = {
id: string;
name: string;
- backgroundType?: "color" | "gradient" | "image";
+ backgroundType?: "color" | "gradient" | "image" | "video";
backgroundColor?: string;
backgroundGradient?: {
from: string;
@@ -13,6 +13,7 @@ type ViewerDataPage = {
angle: number;
};
backgroundImageUrl?: string;
+ backgroundVideoUrl?: string;
objects: Array<{
id: string;
type: string;
@@ -200,6 +201,7 @@ export function transformViewerDataToPages(data: ViewerData): PageData[] {
backgroundColor: page.backgroundColor,
backgroundGradient: page.backgroundGradient,
backgroundImageUrl: page.backgroundImageUrl,
+ backgroundVideoUrl: page.backgroundVideoUrl,
};
});
}
diff --git a/src/pages/viewer/utils/pageBackground.ts b/src/pages/viewer/utils/pageBackground.ts
index de2710d..c571ed7 100644
--- a/src/pages/viewer/utils/pageBackground.ts
+++ b/src/pages/viewer/utils/pageBackground.ts
@@ -1,10 +1,11 @@
import type { PageData } from "@/pages/viewer/types";
export type PageBackgroundDefaults = {
- backgroundType?: "color" | "gradient" | "image";
+ backgroundType?: "color" | "gradient" | "image" | "video";
backgroundColor?: string;
backgroundGradient?: { from: string; to: string; angle: number };
backgroundImageUrl?: string;
+ backgroundVideoUrl?: string;
};
/** ترکیب پسزمینهٔ اختصاصی صفحه با مقادیر پیشفرض سند (همان قاعدهٔ استفادهشده در BookViewer) */
@@ -14,5 +15,6 @@ export function resolvePageBackground(page: PageData, defaults: PageBackgroundDe
backgroundColor: page.backgroundColor ?? defaults.backgroundColor ?? "#ffffff",
backgroundGradient: page.backgroundGradient ?? defaults.backgroundGradient ?? { from: "#ffffff", to: "#ffffff", angle: 0 },
backgroundImageUrl: page.backgroundImageUrl ?? defaults.backgroundImageUrl ?? "",
+ backgroundVideoUrl: page.backgroundVideoUrl ?? defaults.backgroundVideoUrl ?? "",
};
}
diff --git a/src/pages/viewer/utils/pageMediaUrls.ts b/src/pages/viewer/utils/pageMediaUrls.ts
index c055288..84f1587 100644
--- a/src/pages/viewer/utils/pageMediaUrls.ts
+++ b/src/pages/viewer/utils/pageMediaUrls.ts
@@ -34,6 +34,8 @@ export function extractPageMediaAssets(
for (const page of pages) {
if (page.backgroundType === 'image') {
addImageUrl(assets, page.backgroundImageUrl);
+ } else if (page.backgroundType === 'video') {
+ addVideoUrl(assets, page.backgroundVideoUrl);
}
for (const element of page.elements) {
@@ -51,6 +53,8 @@ export function extractPageMediaAssets(
if (documentSettings?.backgroundType === 'image') {
addImageUrl(assets, documentSettings.backgroundImageUrl);
+ } else if (documentSettings?.backgroundType === 'video') {
+ addVideoUrl(assets, documentSettings.backgroundVideoUrl);
}
return Array.from(assets.values());