| 1 | "use client"; |
| 2 | |
| 3 | import React from "react"; |
| 4 | |
| 5 | import { type PlateSlide } from "../utils/parser"; |
| 6 | import { PresentationRoot } from "./components/PresentationRoot"; |
| 7 | import { StaticPlate } from "./components/StaticPlate"; |
| 8 | import { slideSignature } from "./utils/slideSignature"; |
| 9 | |
| 10 | interface PresentationEditorStaticViewProps { |
| 11 | initialContent?: PlateSlide; |
| 12 | className?: string; |
| 13 | id: string; |
| 14 | isPresenting?: boolean; |
| 15 | } |
| 16 | |
| 17 | // slideSignature is imported from utils to keep behavior identical |
| 18 | |
| 19 | const StaticPresentationEditor = React.memo( |
| 20 | ({ |
| 21 | initialContent, |
| 22 | className, |
| 23 | id, |
| 24 | isPresenting = false, |
| 25 | }: PresentationEditorStaticViewProps) => { |
| 26 | return ( |
| 27 | <PresentationRoot |
| 28 | className={className} |
| 29 | fontsToLoad={[]} |
| 30 | isPresenting={isPresenting} |
| 31 | readOnly={true} |
| 32 | isStatic={true} |
| 33 | initialContent={initialContent} |
| 34 | > |
| 35 | <StaticPlate initialContent={initialContent} id={id} /> |
| 36 | </PresentationRoot> |
| 37 | ); |
| 38 | }, |
| 39 | (prev, next) => { |
| 40 | if (prev.id !== next.id) return false; |
| 41 | if (prev.isPresenting !== next.isPresenting) return false; |
| 42 | if ( |
| 43 | slideSignature(prev.initialContent) !== |
| 44 | slideSignature(next.initialContent) |
| 45 | ) |
| 46 | return false; |
| 47 | if (prev.className !== next.className) return false; |
| 48 | return true; |
| 49 | }, |
| 50 | ); |
| 51 | |
| 52 | export default StaticPresentationEditor; |
| 53 |