import { Badge, PreviewPanel, Tooltip } from "@cloudhal/ui"; import type { ReactNode } from "react"; import { useT } from "../i18n/index.tsx"; /** * Localised `PreviewPanel` for an editor; fills the editor's preview column and reloads whenever * the saved `rev` changes. With `srcDoc` (the term editor) it shows the server's rendering of the * unsaved draft instead, so there is nothing "unsaved" to warn about. */ export function EditorPreview({ src, rev, name, dirty, draft, srcDoc, stale, status, }: { src: string; rev: number; name: string; /** The form has changes the preview can't show yet. */ dirty: boolean; /** Show `srcDoc`, the server's rendering of the unsaved form, instead of the saved `src`. */ draft?: boolean; /** That rendering (`undefined` while the first one loads). */ srcDoc?: string | undefined; /** A newer draft document is on its way. */ stale?: boolean; /** Replaces the "Unsaved changes" badge (e.g. the archive's indexing state). */ status?: ReactNode; }) { const t = useT(); const live = srcDoc !== undefined || draft === true; return ( {t("preview.unsaved")} ) : undefined) } /> ); }