| 1 | "use client"; |
| 2 | |
| 3 | import { type PlateEditor } from "platejs/react"; |
| 4 | import { useEffect } from "react"; |
| 5 | |
| 6 | export function useSlideFocus( |
| 7 | editor: PlateEditor, |
| 8 | currentSlideId: string | null, |
| 9 | slideId: string | undefined, |
| 10 | ) { |
| 11 | useEffect(() => { |
| 12 | if (currentSlideId === slideId) { |
| 13 | setTimeout(() => { |
| 14 | try { |
| 15 | editor?.tf?.focus({ edge: "endEditor" }); |
| 16 | } catch {} |
| 17 | }, 100); |
| 18 | } |
| 19 | }, [currentSlideId, slideId, editor]); |
| 20 | } |
| 21 |