diff --git a/apps/client/public/locales/en-US/translation.json b/apps/client/public/locales/en-US/translation.json
index 159a7a61..edd6458f 100644
--- a/apps/client/public/locales/en-US/translation.json
+++ b/apps/client/public/locales/en-US/translation.json
@@ -77,6 +77,7 @@
"Failed to fetch recent pages": "Failed to fetch recent pages",
"Failed to import pages": "Failed to import pages",
"Failed to load page. An error occurred.": "Failed to load page. An error occurred.",
+ "Failed to load presentation. An error occurred.": "Failed to load presentation. An error occurred.",
"Failed to update data": "Failed to update data",
"Failed to create base": "Failed to create base",
"Failed to update base": "Failed to update base",
@@ -167,6 +168,7 @@
"Exit presentation mode": "Exit presentation mode",
"Enter fullscreen": "Enter fullscreen",
"Exit fullscreen": "Exit fullscreen",
+ "Laser pointer": "Laser pointer",
"Slide {{current}} of {{total}}": "Slide {{current}} of {{total}}",
"Print PDF": "Print PDF",
"Profile": "Profile",
diff --git a/apps/client/src/features/editor/components/presentation/laser-pointer.test.tsx b/apps/client/src/features/editor/components/presentation/laser-pointer.test.tsx
new file mode 100644
index 00000000..d4c59658
--- /dev/null
+++ b/apps/client/src/features/editor/components/presentation/laser-pointer.test.tsx
@@ -0,0 +1,90 @@
+import { describe, expect, it } from "vitest";
+import { render } from "@testing-library/react";
+import LaserPointer from "./laser-pointer";
+
+type PointerInit = MouseEventInit & { pointerType?: string };
+
+function dispatchPointer(
+ target: EventTarget,
+ type: "pointermove" | "pointerout",
+ init: PointerInit = {},
+) {
+ // jsdom has no PointerEvent
+ const event = new MouseEvent(type, { bubbles: true, ...init });
+ Object.defineProperty(event, "pointerType", {
+ value: init.pointerType ?? "mouse",
+ });
+ target.dispatchEvent(event);
+}
+
+function renderLaserPointer(enabled = true) {
+ const view = render();
+ return { ...view, dot: view.container.firstElementChild as HTMLElement };
+}
+
+describe("LaserPointer", () => {
+ it("follows the pointer", () => {
+ const { dot } = renderLaserPointer();
+
+ dispatchPointer(window, "pointermove", { clientX: 120, clientY: 80 });
+
+ expect(dot.style.transform).toBe("translate(120px, 80px)");
+ expect(dot.style.visibility).toBe("visible");
+ });
+
+ it("stays hidden while disabled", () => {
+ const { dot } = renderLaserPointer(false);
+
+ dispatchPointer(window, "pointermove", { clientX: 120, clientY: 80 });
+
+ expect(dot.hidden).toBe(true);
+ });
+
+ it("shows at the last pointer position once enabled", () => {
+ const { dot, rerender } = renderLaserPointer(false);
+ dispatchPointer(window, "pointermove", { clientX: 120, clientY: 80 });
+
+ rerender();
+
+ expect(dot.hidden).toBe(false);
+ expect(dot.style.transform).toBe("translate(120px, 80px)");
+ });
+
+ it("hides for touch input", () => {
+ const { dot } = renderLaserPointer();
+ dispatchPointer(window, "pointermove", { clientX: 120, clientY: 80 });
+
+ dispatchPointer(window, "pointermove", { pointerType: "touch" });
+
+ expect(dot.style.visibility).toBe("hidden");
+ });
+
+ it("hides when the pointer leaves the window", () => {
+ const { dot, container } = renderLaserPointer();
+ dispatchPointer(window, "pointermove", { clientX: 120, clientY: 80 });
+
+ dispatchPointer(container, "pointerout", { relatedTarget: null });
+
+ expect(dot.style.visibility).toBe("hidden");
+ });
+
+ it("hides when the pointer moves over an embed", () => {
+ const { dot, container } = renderLaserPointer();
+ const embed = container.appendChild(document.createElement("iframe"));
+ dispatchPointer(window, "pointermove", { clientX: 120, clientY: 80 });
+
+ dispatchPointer(container, "pointerout", { relatedTarget: embed });
+
+ expect(dot.style.visibility).toBe("hidden");
+ });
+
+ it("stays visible when the pointer moves onto another page element", () => {
+ const { dot, container } = renderLaserPointer();
+ const paragraph = container.appendChild(document.createElement("p"));
+ dispatchPointer(window, "pointermove", { clientX: 120, clientY: 80 });
+
+ dispatchPointer(container, "pointerout", { relatedTarget: paragraph });
+
+ expect(dot.style.visibility).toBe("visible");
+ });
+});
diff --git a/apps/client/src/features/editor/components/presentation/laser-pointer.tsx b/apps/client/src/features/editor/components/presentation/laser-pointer.tsx
new file mode 100644
index 00000000..b35c5bc3
--- /dev/null
+++ b/apps/client/src/features/editor/components/presentation/laser-pointer.tsx
@@ -0,0 +1,36 @@
+import { useRef } from "react";
+import { useWindowEvent } from "@mantine/hooks";
+import classes from "./presentation-modal.module.css";
+
+type LaserPointerProps = {
+ enabled: boolean;
+};
+
+export default function LaserPointer({ enabled }: LaserPointerProps) {
+ const dotRef = useRef(null);
+
+ useWindowEvent("pointermove", (event) => {
+ const dot = dotRef.current;
+ if (!dot) return;
+ dot.style.transform = `translate(${event.clientX}px, ${event.clientY}px)`;
+ dot.style.visibility = event.pointerType === "touch" ? "hidden" : "visible";
+ });
+
+ useWindowEvent("pointerout", (event) => {
+ // the page gets no pointer events outside the window or over an embed
+ const leftPage =
+ !event.relatedTarget || event.relatedTarget instanceof HTMLIFrameElement;
+ if (leftPage && dotRef.current) {
+ dotRef.current.style.visibility = "hidden";
+ }
+ });
+
+ return (
+
+ );
+}
diff --git a/apps/client/src/features/editor/components/presentation/presentation-modal.module.css b/apps/client/src/features/editor/components/presentation/presentation-modal.module.css
index fc079cc3..58c2c3e3 100644
--- a/apps/client/src/features/editor/components/presentation/presentation-modal.module.css
+++ b/apps/client/src/features/editor/components/presentation/presentation-modal.module.css
@@ -53,7 +53,7 @@
.editorContainer {
width: 100%;
- max-width: 900px;
+ max-width: 1440px;
margin-block: auto;
}
@@ -79,7 +79,7 @@
align-items: center;
justify-content: center;
width: 100%;
- max-width: 900px;
+ max-width: 1440px;
margin-block: auto;
text-align: center;
}
@@ -132,3 +132,23 @@
height: 24px;
margin-inline: 4px;
}
+
+/* the dot replaces every cursor, including ones slide content sets */
+.content:has(.laserPointer:not([hidden])),
+.content:has(.laserPointer:not([hidden])) * {
+ cursor: none !important;
+}
+
+.laserPointer {
+ position: fixed;
+ top: -7px;
+ left: -7px;
+ z-index: 20;
+ width: 14px;
+ height: 14px;
+ border-radius: 50%;
+ background-color: color-mix(in srgb, var(--mantine-color-blue-4) 65%, transparent);
+ box-shadow: 0 0 10px 4px color-mix(in srgb, var(--mantine-color-blue-4) 30%, transparent);
+ pointer-events: none;
+ visibility: hidden;
+}
diff --git a/apps/client/src/features/editor/components/presentation/presentation-modal.tsx b/apps/client/src/features/editor/components/presentation/presentation-modal.tsx
index ec64947b..e6f8d0e3 100644
--- a/apps/client/src/features/editor/components/presentation/presentation-modal.tsx
+++ b/apps/client/src/features/editor/components/presentation/presentation-modal.tsx
@@ -13,6 +13,8 @@ import {
import {
ActionIcon,
Box,
+ Button,
+ Center,
Divider,
Modal,
Title,
@@ -20,10 +22,12 @@ import {
VisuallyHidden,
} from "@mantine/core";
import {
+ IconAlertTriangle,
IconChevronLeft,
IconChevronRight,
IconMaximize,
IconMinimize,
+ IconPointer,
IconX,
} from "@tabler/icons-react";
import { useFullscreenDocument, useWindowEvent } from "@mantine/hooks";
@@ -38,10 +42,13 @@ import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
import { UniqueID } from "@docmost/editor-ext";
import { useTranslation } from "react-i18next";
import { useParams } from "react-router-dom";
+import { ErrorBoundary } from "react-error-boundary";
import clsx from "clsx";
+import { EmptyState } from "@/components/ui/empty-state.tsx";
import { mainExtensions } from "@/features/editor/extensions/extensions";
import { TransclusionLookupProvider } from "@/features/editor/components/transclusion/transclusion-lookup-context";
import { extractPageSlugId } from "@/lib";
+import LaserPointer from "./laser-pointer";
import {
findSlideIndexForNode,
getContentBoxHeight,
@@ -130,12 +137,33 @@ export default function PresentationModal({
aria-label={t("Presentation mode")}
>
-
+
+
+ {t("Close")}
+
+ }
+ />
+
+ }
+ >
+
+
@@ -162,6 +190,7 @@ function PresentationDeck({
const { toggle: toggleFullscreen, fullscreen } = useFullscreenDocument();
const canFullscreen = document.fullscreenEnabled;
+ const [laserPointerEnabled, setLaserPointerEnabled] = useState(false);
useEffect(
() => () => {
@@ -434,36 +463,50 @@ function PresentationDeck({
+
+
+
+ setLaserPointerEnabled((enabled) => !enabled)}
+ >
+
+
+
+
{canFullscreen && (
- <>
-
-
+
-
- {fullscreen ? (
-
- ) : (
-
- )}
-
-
- >
+ {fullscreen ? (
+
+ ) : (
+
+ )}
+
+
)}
@@ -474,6 +517,8 @@ function PresentationDeck({
})}
+
+
);
}