diff --git a/app/scenes/Document/components/PresentationMode.tsx b/app/scenes/Document/components/PresentationMode.tsx
index 1ad215be66..1eb37388af 100644
--- a/app/scenes/Document/components/PresentationMode.tsx
+++ b/app/scenes/Document/components/PresentationMode.tsx
@@ -33,7 +33,8 @@ type Slide =
icon?: string | null;
iconColor?: string | null;
}
- | { type: "content"; content: ProsemirrorData[] };
+ | { type: "content"; content: ProsemirrorData[] }
+ | { type: "instructions" };
interface Props {
/** The document title. */
@@ -48,6 +49,19 @@ interface Props {
onClose: () => void;
}
+/**
+ * Returns true if the given content nodes contain no meaningful text or elements.
+ *
+ * @param nodes the prosemirror content nodes.
+ * @returns true when every node is an empty paragraph.
+ */
+function isContentEmpty(nodes: ProsemirrorData[]): boolean {
+ return nodes.every(
+ (node) =>
+ node.type === "paragraph" && (!node.content || node.content.length === 0)
+ );
+}
+
/**
* Splits a ProseMirror document into slides based on heading and divider nodes.
* A dedicated title slide is prepended. Each h1/h2 heading or horizontal rule
@@ -114,10 +128,21 @@ function PresentationMode({ title, icon, iconColor, data, onClose }: Props) {
const [isFullscreen, setIsFullscreen] = React.useState(false);
const isIdle = useIdle(3000, idleEvents);
- const slides = React.useMemo(
- () => splitIntoSlides(data, title, icon, iconColor),
- [data, title, icon, iconColor]
- );
+ const slides = React.useMemo(() => {
+ const result = splitIntoSlides(data, title, icon, iconColor);
+ const contentSlides = result.filter((s) => s.type === "content");
+ const hasContent =
+ contentSlides.length > 0 &&
+ contentSlides.some(
+ (s) => s.type === "content" && !isContentEmpty(s.content)
+ );
+
+ if (!hasContent) {
+ return [result[0], { type: "instructions" as const }];
+ }
+
+ return result;
+ }, [data, title, icon, iconColor]);
const totalSlides = slides.length;
@@ -300,6 +325,24 @@ function PresentationMode({ title, icon, iconColor, data, onClose }: Props) {
)}
{slide.title}
+ ) : slide.type === "instructions" ? (
+
+
+ {t("Create your presentation")}
+
+
+ {t(
+ "Add content to your document, then use headings or dividers to separate it into slides."
+ )}{" "}
+
+ {t("Learn more")}
+
+ .
+
+
) : slideData ? (
{{ documentTitle }} document will delete all of its history.": "Are you sure about that? Deleting the {{ documentTitle }} document will delete all of its history.",