Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat: add Notes teleprompter mode

My-Denia44e164837c03
diff --git a/src/components/launch/NotesToolbar.browser.test.tsx b/src/components/launch/NotesToolbar.browser.test.tsx
new file mode 100644
index 000000000..47889c730
--- /dev/null
+++ b/src/components/launch/NotesToolbar.browser.test.tsx
@@ -0,0 +1,131 @@
+import "@/index.css";
+import type { Editor } from "@tiptap/react";
+import { useState } from "react";
+import { flushSync } from "react-dom";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { userEvent } from "vitest/browser";
+import { NotesToolbar } from "./NotesToolbar";
+
+vi.mock("@/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: React.ReactNode }) => children,
+}));
+
+vi.mock("@/contexts/I18nContext", () => ({
+ useScopedT: () => (key: string) => {
+ const labels: Record<string, string> = {
+ "tooltips.notesToolbar.play": "Play",
+ "tooltips.notesToolbar.pause": "Pause",
+ "tooltips.notesToolbar.speed": "Scroll speed",
+ "tooltips.notesToolbar.decreaseSpeed": "Decrease scroll speed",
+ "tooltips.notesToolbar.increaseSpeed": "Increase scroll speed",
+ "tooltips.notesToolbar.fontSize": "Font size",
+ "tooltips.notesToolbar.decreaseFontSize": "Decrease font size",
+ "tooltips.notesToolbar.increaseFontSize": "Increase font size",
+ "tooltips.notesToolbar.mirror": "Mirror",
+ };
+ return labels[key] ?? key;
+ },
+}));
+
+function createEditor(): Editor {
+ const chain: Record<string, ReturnType<typeof vi.fn>> = {};
+ for (const command of [
+ "focus",
+ "toggleBold",
+ "toggleItalic",
+ "toggleStrike",
+ "toggleBulletList",
+ "toggleOrderedList",
+ "toggleBlockquote",
+ "toggleCodeBlock",
+ ]) {
+ chain[command] = vi.fn(() => chain);
+ }
+ chain.run = vi.fn(() => true);
+
+ return {
+ can: () => ({ chain: () => chain }),
+ chain: () => chain,
+ isActive: () => false,
+ on: vi.fn(),
+ off: vi.fn(),
+ } as unknown as Editor;
+}
+
+function ToolbarHarness() {
+ const [isPlaying, setIsPlaying] = useState(false);
+ const [speed, setSpeed] = useState(40);
+ const [fontSize, setFontSize] = useState(16);
+ const [mirrored, setMirrored] = useState(false);
+
+ return (
+ <NotesToolbar
+ editor={createEditor()}
+ isPlaying={isPlaying}
+ speed={speed}
+ fontSize={fontSize}
+ mirrored={mirrored}
+ onTogglePlaying={() => setIsPlaying((current) => !current)}
+ onDecreaseSpeed={() => setSpeed((current) => current - 10)}
+ onIncreaseSpeed={() => setSpeed((current) => current + 10)}
+ onDecreaseFontSize={() => setFontSize((current) => current - 2)}
+ onIncreaseFontSize={() => setFontSize((current) => current + 2)}
+ onToggleMirror={() => setMirrored((current) => !current)}
+ />
+ );
+}
+
+describe("NotesToolbar narrow-width reachability", () => {
+ let root: Root | null = null;
+ let host: HTMLDivElement | null = null;
+
+ afterEach(() => {
+ root?.unmount();
+ host?.remove();
+ root = null;
+ host = null;
+ });
+
+ it("keeps every teleprompter control reachable at a severe 160px width", async () => {
+ host = document.createElement("div");
+ host.style.width = "160px";
+ document.body.append(host);
+ root = createRoot(host);
+ flushSync(() => root?.render(<ToolbarHarness />));
+
+ const row = host.querySelector<HTMLElement>('[data-testid="notes-teleprompter-controls"]');
+ const controls = Array.from(
+ host.querySelectorAll<HTMLButtonElement>("[data-teleprompter-control]"),
+ );
+ if (!row || controls.length === 0) {
+ throw new Error("Teleprompter controls did not render");
+ }
+
+ expect(row.scrollWidth).toBeGreaterThan(row.clientWidth);
+ await userEvent.wheel(row, { delta: { x: row.scrollWidth } });
+ await new Promise(requestAnimationFrame);
+ expect(row.scrollLeft).toBeGreaterThan(0);
+
+ const rowRect = row.getBoundingClientRect();
+ const lastRect = controls.at(-1)?.getBoundingClientRect();
+ expect(lastRect).toBeDefined();
+ expect(lastRect!.left).toBeGreaterThanOrEqual(rowRect.left - 1);
+ expect(lastRect!.right).toBeLessThanOrEqual(rowRect.right + 1);
+
+ controls[0]?.focus();
+ expect(document.activeElement).toBe(controls[0]);
+ for (let index = 1; index < controls.length; index++) {
+ await userEvent.tab();
+ expect(document.activeElement).toBe(controls[index]);
+ }
+
+ controls[0]?.focus();
+ await userEvent.keyboard("{Enter}");
+ expect(controls[0]?.getAttribute("aria-label")).toBe("Pause");
+
+ const mirror = controls.at(-1)!;
+ await userEvent.click(mirror);
+ expect(mirror.getAttribute("aria-pressed")).toBe("true");
+ });
+});
diff --git a/src/components/launch/NotesToolbar.test.tsx b/src/components/launch/NotesToolbar.test.tsx
new file mode 100644
index 000000000..e95e04c1a
--- /dev/null
+++ b/src/components/launch/NotesToolbar.test.tsx
@@ -0,0 +1,117 @@
+import "@testing-library/jest-dom";
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import type { Editor } from "@tiptap/react";
+import { describe, expect, it, vi } from "vitest";
+import { NotesToolbar, type NotesToolbarProps } from "./NotesToolbar";
+
+vi.mock("@/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: React.ReactNode }) => children,
+}));
+
+vi.mock("@/contexts/I18nContext", () => ({
+ useScopedT: () => (key: string) => {
+ const labels: Record<string, string> = {
+ "tooltips.notesToolbar.play": "Play",
+ "tooltips.notesToolbar.pause": "Pause",
+ "tooltips.notesToolbar.speed": "Scroll speed",
+ "tooltips.notesToolbar.decreaseSpeed": "Decrease scroll speed",
+ "tooltips.notesToolbar.increaseSpeed": "Increase scroll speed",
+ "tooltips.notesToolbar.fontSize": "Font size",
+ "tooltips.notesToolbar.decreaseFontSize": "Decrease font size",
+ "tooltips.notesToolbar.increaseFontSize": "Increase font size",
+ "tooltips.notesToolbar.mirror": "Mirror",
+ };
+ return labels[key] ?? key;
+ },
+}));
+
+function createEditor(): Editor {
+ const chain: Record<string, ReturnType<typeof vi.fn>> = {};
+ for (const command of [
+ "focus",
+ "toggleBold",
+ "toggleItalic",
+ "toggleStrike",
+ "toggleBulletList",
+ "toggleOrderedList",
+ "toggleBlockquote",
+ "toggleCodeBlock",
+ ]) {
+ chain[command] = vi.fn(() => chain);
+ }
+ chain.run = vi.fn(() => true);
+
+ return {
+ can: () => ({ chain: () => chain }),
+ chain: () => chain,
+ isActive: () => false,
+ on: vi.fn(),
+ off: vi.fn(),
+ } as unknown as Editor;
+}
+
+function createProps(overrides: Partial<NotesToolbarProps> = {}): NotesToolbarProps {
+ return {
+ editor: createEditor(),
+ isPlaying: false,
+ speed: 40,
+ fontSize: 16,
+ mirrored: false,
+ onTogglePlaying: vi.fn(),
+ onDecreaseSpeed: vi.fn(),
+ onIncreaseSpeed: vi.fn(),
+ onDecreaseFontSize: vi.fn(),
+ onIncreaseFontSize: vi.fn(),
+ onToggleMirror: vi.fn(),
+ ...overrides,
+ };
+}
+
+describe("NotesToolbar teleprompter controls", () => {
+ it("exposes values and dispatches every manual control", async () => {
+ const user = userEvent.setup();
+ const props = createProps();
+ render(<NotesToolbar {...props} />);
+
+ expect(screen.getByRole("status", { name: "Scroll speed" })).toHaveTextContent("40 px/s");
+ expect(screen.getByRole("status", { name: "Font size" })).toHaveTextContent("16 px");
+ expect(screen.getByRole("button", { name: "Mirror" })).toHaveAttribute("aria-pressed", "false");
+ expect(screen.getByRole("button", { name: "Decrease scroll speed" })).not.toHaveAttribute(
+ "aria-pressed",
+ );
+ expect(screen.getByRole("button", { name: "Increase font size" })).not.toHaveAttribute(
+ "aria-pressed",
+ );
+
+ await user.click(screen.getByRole("button", { name: "Play" }));
+ await user.click(screen.getByRole("button", { name: "Decrease scroll speed" }));
+ await user.click(screen.getByRole("button", { name: "Increase scroll speed" }));
+ await user.click(screen.getByRole("button", { name: "Decrease font size" }));
+ await user.click(screen.getByRole("button", { name: "Increase font size" }));
+ await user.click(screen.getByRole("button", { name: "Mirror" }));
+
+ expect(props.onTogglePlaying).toHaveBeenCalledOnce();
+ expect(props.onDecreaseSpeed).toHaveBeenCalledOnce();
+ expect(props.onIncreaseSpeed).toHaveBeenCalledOnce();
+ expect(props.onDecreaseFontSize).toHaveBeenCalledOnce();
+ expect(props.onIncreaseFontSize).toHaveBeenCalledOnce();
+ expect(props.onToggleMirror).toHaveBeenCalledOnce();
+ });
+
+ it("disables controls at their bounds", () => {
+ const { rerender } = render(<NotesToolbar {...createProps({ speed: 10, fontSize: 14 })} />);
+ expect(screen.getByRole("button", { name: "Decrease scroll speed" })).toBeDisabled();
+ expect(screen.getByRole("button", { name: "Decrease font size" })).toBeDisabled();
+
+ rerender(<NotesToolbar {...createProps({ speed: 100, fontSize: 48 })} />);
+ expect(screen.getByRole("button", { name: "Increase scroll speed" })).toBeDisabled();
+ expect(screen.getByRole("button", { name: "Increase font size" })).toBeDisabled();
+ });
+
+ it("keeps playback paused and disabled until the editor is ready", () => {
+ render(<NotesToolbar {...createProps({ editor: null })} />);
+ expect(screen.getByRole("button", { name: "Play" })).toBeDisabled();
+ expect(screen.queryByRole("button", { name: "Pause" })).not.toBeInTheDocument();
+ });
+});
diff --git a/src/components/launch/NotesToolbar.tsx b/src/components/launch/NotesToolbar.tsx
index c744b525c..245347468 100644
--- a/src/components/launch/NotesToolbar.tsx
+++ b/src/components/launch/NotesToolbar.tsx
@@ -1,12 +1,41 @@
import type { Editor } from "@tiptap/react";
-import { Bold, Code, Italic, List, ListOrdered, Quote, Strikethrough } from "lucide-react";
+import {
+ Bold,
+ Code,
+ FlipHorizontal2,
+ Italic,
+ List,
+ ListOrdered,
+ Minus,
+ Pause,
+ Play,
+ Plus,
+ Quote,
+ Strikethrough,
+} from "lucide-react";
import { type ReactNode, useEffect, useReducer } from "react";
import { Tooltip } from "@/components/ui/tooltip";
import { useScopedT } from "@/contexts/I18nContext";
import { cn } from "@/lib/utils";
+import {
+ MAX_NOTES_FONT_SIZE,
+ MAX_TELEPROMPTER_SPEED,
+ MIN_NOTES_FONT_SIZE,
+ MIN_TELEPROMPTER_SPEED,
+} from "./notesTeleprompter";
-type NotesToolbarProps = {
+export type NotesToolbarProps = {
editor: Editor | null;
+ isPlaying: boolean;
+ speed: number;
+ fontSize: number;
+ mirrored: boolean;
+ onTogglePlaying: () => void;
+ onDecreaseSpeed: () => void;
+ onIncreaseSpeed: () => void;
+ onDecreaseFontSize: () => void;
+ onIncreaseFontSize: () => void;
+ onToggleMirror: () => void;
};
type ToolbarButtonProps = {
@@ -14,6 +43,7 @@ type ToolbarButtonProps = {
tooltipContent: string;
active?: boolean;
disabled?: boolean;
+ teleprompterControl?: boolean;
onClick: () => void;
children: ReactNode;
};
@@ -21,8 +51,9 @@ type ToolbarButtonProps = {
function ToolbarButton({
"aria-label": ariaLabel,
tooltipContent,
- active = false,
+ active,
disabled = false,
+ teleprompterControl = false,
onClick,
children,
}: ToolbarButtonProps) {
@@ -33,9 +64,10 @@ function ToolbarButton({
aria-label={ariaLabel}
aria-pressed={active}
disabled={disabled}
+ data-teleprompter-control={teleprompterControl ? "" : undefined}
onClick={onClick}
className={cn(
- "shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-md border-0 bg-transparent text-gray-700 transition-colors hover:bg-gray-200 hover:text-gray-900 disabled:cursor-not-allowed disabled:opacity-35",
+ "shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-md border-0 bg-transparent text-gray-700 transition-colors hover:bg-gray-200 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-violet-600 disabled:cursor-not-allowed disabled:opacity-35",
active && "bg-gray-900 text-white hover:bg-gray-800 hover:text-white",
)}
>
@@ -67,86 +99,199 @@ function useEditorRevision(editor: Editor | null): void {
}, [editor]);
}
-export function NotesToolbar({ editor }: NotesToolbarProps) {
+export function NotesToolbar({
+ editor,
+ isPlaying,
+ speed,
+ fontSize,
+ mirrored,
+ onTogglePlaying,
+ onDecreaseSpeed,
+ onIncreaseSpeed,
+ onDecreaseFontSize,
+ onIncreaseFontSize,
+ onToggleMirror,
+}: NotesToolbarProps) {
useEditorRevision(editor);
const t = useScopedT("launch");
return (
- <div className="flex items-center gap-1 rounded-[0.625rem] max-w-fit border border-gray-200 bg-gray-50 p-1.5 overflow-scroll no-scrollbar">
- <div className="flex items-center justify-between flex-1 shrink-0 gap-1">
- <ToolbarButton
- aria-label={t("tooltips.notesToolbar.bold")}
- tooltipContent={t("tooltips.notesToolbar.bold")}
- active={editor?.isActive("bold") ?? false}
- disabled={!editor?.can().chain().focus().toggleBold().run()}
- onClick={() => editor?.chain().focus().toggleBold().run()}
- >
- <Bold size={16} />
- </ToolbarButton>
- <ToolbarButton
- aria-label={t("tooltips.notesToolbar.italic")}
- tooltipContent={t("tooltips.notesToolbar.italic")}
- active={editor?.isActive("italic") ?? false}
- disabled={!editor?.can().chain().focus().toggleItalic().run()}
- onClick={() => editor?.chain().focus().toggleItalic().run()}
- >
- <Italic size={16} />
- </ToolbarButton>
- <ToolbarButton
- aria-label={t("tooltips.notesToolbar.strikethrough")}
- tooltipContent={t("tooltips.notesToolbar.strikethrough")}
- active={editor?.isActive("strike") ?? false}
- disabled={!editor?.can().chain().focus().toggleStrike().run()}
- onClick={() => editor?.chain().focus().toggleStrike().run()}
- >
- <Strikethrough size={16} />
- </ToolbarButton>
- </div>
- <div className="flex items-center justify-between flex-1 shrink-0 gap-1">
- <div className="h-8 w-5 grid place-content-center">
- <span className="mx-0.5 h-5 w-px bg-gray-300" aria-hidden="true" />
+ <div className="flex w-full min-w-0 max-w-full flex-col gap-1.5 rounded-[0.625rem] border border-gray-200 bg-gray-50 p-1.5">
+ <div
+ data-testid="notes-formatting-controls"
+ className="flex w-full min-w-0 items-center overflow-x-auto"
+ >
+ <div className="flex min-w-max items-center gap-1">
+ <div className="flex shrink-0 items-center gap-1">
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.bold")}
+ tooltipContent={t("tooltips.notesToolbar.bold")}
+ active={editor?.isActive("bold") ?? false}
+ disabled={!editor?.can().chain().focus().toggleBold().run()}
+ onClick={() => editor?.chain().focus().toggleBold().run()}
+ >
+ <Bold size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.italic")}
+ tooltipContent={t("tooltips.notesToolbar.italic")}
+ active={editor?.isActive("italic") ?? false}
+ disabled={!editor?.can().chain().focus().toggleItalic().run()}
+ onClick={() => editor?.chain().focus().toggleItalic().run()}
+ >
+ <Italic size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.strikethrough")}
+ tooltipContent={t("tooltips.notesToolbar.strikethrough")}
+ active={editor?.isActive("strike") ?? false}
+ disabled={!editor?.can().chain().focus().toggleStrike().run()}
+ onClick={() => editor?.chain().focus().toggleStrike().run()}
+ >
+ <Strikethrough size={16} />
+ </ToolbarButton>
+ </div>
+ <div className="grid h-8 w-5 shrink-0 place-content-center">
+ <span className="mx-0.5 h-5 w-px bg-gray-300" aria-hidden="true" />
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.bulletList")}
+ tooltipContent={t("tooltips.notesToolbar.bulletList")}
+ active={editor?.isActive("bulletList") ?? false}
+ disabled={!editor?.can().chain().focus().toggleBulletList().run()}
+ onClick={() => editor?.chain().focus().toggleBulletList().run()}
+ >
+ <List size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.numberedList")}
+ tooltipContent={t("tooltips.notesToolbar.numberedList")}
+ active={editor?.isActive("orderedList") ?? false}
+ disabled={!editor?.can().chain().focus().toggleOrderedList().run()}
+ onClick={() => editor?.chain().focus().toggleOrderedList().run()}
+ >
+ <ListOrdered size={16} />
+ </ToolbarButton>
+ </div>
+ <div className="grid h-8 w-5 shrink-0 place-content-center">
+ <span className="mx-0.5 h-5 w-px bg-gray-300" aria-hidden="true" />
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.blockquote")}
+ tooltipContent={t("tooltips.notesToolbar.blockquote")}
+ active={editor?.isActive("blockquote") ?? false}
+ disabled={!editor?.can().chain().focus().toggleBlockquote().run()}
+ onClick={() => editor?.chain().focus().toggleBlockquote().run()}
+ >
+ <Quote size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.codeBlock")}
+ tooltipContent={t("tooltips.notesToolbar.codeBlock")}
+ active={editor?.isActive("codeBlock") ?? false}
+ disabled={!editor?.can().chain().focus().toggleCodeBlock().run()}
+ onClick={() => editor?.chain().focus().toggleCodeBlock().run()}
+ >
+ <Code size={16} />
+ </ToolbarButton>
+ </div>
</div>
- <ToolbarButton
- aria-label={t("tooltips.notesToolbar.bulletList")}
- tooltipContent={t("tooltips.notesToolbar.bulletList")}
- active={editor?.isActive("bulletList") ?? false}
- disabled={!editor?.can().chain().focus().toggleBulletList().run()}
- onClick={() => editor?.chain().focus().toggleBulletList().run()}
- >
- <List size={16} />
- </ToolbarButton>
- <ToolbarButton
- aria-label={t("tooltips.notesToolbar.numberedList")}
- tooltipContent={t("tooltips.notesToolbar.numberedList")}
- active={editor?.isActive("orderedList") ?? false}
- disabled={!editor?.can().chain().focus().toggleOrderedList().run()}
- onClick={() => editor?.chain().focus().toggleOrderedList().run()}
- >
- <ListOrdered size={16} />
- </ToolbarButton>
</div>
- <div className="flex items-center justify-between flex-1 shrink-0 gap-1">
- <div className="h-8 w-5 grid place-content-center">
- <span className="mx-0.5 h-5 w-px bg-gray-300" aria-hidden="true" />
+
+ <div
+ data-testid="notes-teleprompter-controls"
+ className="flex w-full min-w-0 items-center overflow-x-auto"
+ >
+ <div className="flex min-w-max items-center gap-1">
+ <ToolbarButton
+ aria-label={t(isPlaying ? "tooltips.notesToolbar.pause" : "tooltips.notesToolbar.play")}
+ tooltipContent={t(
+ isPlaying ? "tooltips.notesToolbar.pause" : "tooltips.notesToolbar.play",
+ )}
+ active={isPlaying}
+ disabled={!editor}
+ teleprompterControl
+ onClick={onTogglePlaying}
+ >
+ {isPlaying ? <Pause size={16} /> : <Play size={16} />}
+ </ToolbarButton>
+
+ <div
+ role="group"
+ aria-label={t("tooltips.notesToolbar.speed")}
+ className="flex shrink-0 items-center gap-1"
+ >
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.decreaseSpeed")}
+ tooltipContent={t("tooltips.notesToolbar.decreaseSpeed")}
+ disabled={speed <= MIN_TELEPROMPTER_SPEED}
+ teleprompterControl
+ onClick={onDecreaseSpeed}
+ >
+ <Minus size={16} />
+ </ToolbarButton>
+ <output
+ aria-label={t("tooltips.notesToolbar.speed")}
+ aria-live="polite"
+ className="min-w-14 text-center text-xs tabular-nums text-gray-700"
+ >
+ {speed} px/s
+ </output>
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.increaseSpeed")}
+ tooltipContent={t("tooltips.notesToolbar.increaseSpeed")}
+ disabled={speed >= MAX_TELEPROMPTER_SPEED}
+ teleprompterControl
+ onClick={onIncreaseSpeed}
+ >
+ <Plus size={16} />
+ </ToolbarButton>
+ </div>
+
+ <div
+ role="group"
+ aria-label={t("tooltips.notesToolbar.fontSize")}
+ className="flex shrink-0 items-center gap-1"
+ >
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.decreaseFontSize")}
+ tooltipContent={t("tooltips.notesToolbar.decreaseFontSize")}
+ disabled={fontSize <= MIN_NOTES_FONT_SIZE}
+ teleprompterControl
+ onClick={onDecreaseFontSize}
+ >
+ <Minus size={16} />
+ </ToolbarButton>
+ <output
+ aria-label={t("tooltips.notesToolbar.fontSize")}
+ aria-live="polite"
+ className="min-w-10 text-center text-xs tabular-nums text-gray-700"
+ >
+ {fontSize} px
+ </output>
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.increaseFontSize")}
+ tooltipContent={t("tooltips.notesToolbar.increaseFontSize")}
+ disabled={fontSize >= MAX_NOTES_FONT_SIZE}
+ teleprompterControl
+ onClick={onIncreaseFontSize}
+ >
+ <Plus size={16} />
+ </ToolbarButton>
+ </div>
+
+ <ToolbarButton
+ aria-label={t("tooltips.notesToolbar.mirror")}
+ tooltipContent={t("tooltips.notesToolbar.mirror")}
+ active={mirrored}
+ teleprompterControl
+ onClick={onToggleMirror}
+ >
+ <FlipHorizontal2 size={16} />
+ </ToolbarButton>
</div>
- <ToolbarButton
- aria-label={t("tooltips.notesToolbar.blockquote")}
- tooltipContent={t("tooltips.notesToolbar.blockquote")}
- active={editor?.isActive("blockquote") ?? false}
- disabled={!editor?.can().chain().focus().toggleBlockquote().run()}
- onClick={() => editor?.chain().focus().toggleBlockquote().run()}
- >
- <Quote size={16} />
- </ToolbarButton>
- <ToolbarButton
- aria-label={t("tooltips.notesToolbar.codeBlock")}
- tooltipContent={t("tooltips.notesToolbar.codeBlock")}
- active={editor?.isActive("codeBlock") ?? false}
- disabled={!editor?.can().chain().focus().toggleCodeBlock().run()}
- onClick={() => editor?.chain().focus().toggleCodeBlock().run()}
- >
- <Code size={16} />
- </ToolbarButton>
</div>
</div>
);
diff --git a/src/components/launch/NotesWindow.module.css b/src/components/launch/NotesWindow.module.css
index b0b0cf38a..cda0a410a 100644
--- a/src/components/launch/NotesWindow.module.css
+++ b/src/components/launch/NotesWindow.module.css
@@ -8,6 +8,14 @@
caret-color: #111827;
}
+:global(.notes-teleprompter-content) {
+ transform-origin: center;
+}
+
+:global(.notes-teleprompter-content[data-mirrored="true"]) {
+ transform: scaleX(-1);
+}
+
:global(.tiptap) :first-child {
margin-top: 0;
}
@@ -66,28 +74,28 @@
}
:global(.tiptap) h1 {
- font-size: 1.4rem;
+ font-size: 1.4em;
}
:global(.tiptap) h2 {
- font-size: 1.2rem;
+ font-size: 1.2em;
}
:global(.tiptap) h3 {
- font-size: 1.1rem;
+ font-size: 1.1em;
}
:global(.tiptap) h4,
:global(.tiptap) h5,
:global(.tiptap) h6 {
- font-size: 1rem;
+ font-size: 1em;
}
:global(.tiptap) code {
background-color: #ede9fe;
border-radius: 0.4rem;
color: #111827;
- font-size: 0.85rem;
+ font-size: 0.85em;
padding: 0.25em 0.3em;
}
@@ -103,7 +111,7 @@
:global(.tiptap) pre code {
background: none;
color: inherit;
- font-size: 0.8rem;
+ font-size: 0.8em;
padding: 0;
}
diff --git a/src/components/launch/NotesWindow.test.tsx b/src/components/launch/NotesWindow.test.tsx
new file mode 100644
index 000000000..c0ebb9fb0
--- /dev/null
+++ b/src/components/launch/NotesWindow.test.tsx
@@ -0,0 +1,216 @@
+import "@testing-library/jest-dom";
+import { act, render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import type { Editor } from "@tiptap/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { NotesWindow } from "./NotesWindow";
+import { NOTES_TELEPROMPTER_STORAGE_KEY } from "./notesTeleprompter";
+
+const tiptapState = vi.hoisted(() => ({
+ options: null as null | {
+ content: string;
+ onUpdate: (payload: { editor: { getHTML: () => string } }) => void;
+ },
+ editor: null as Editor | null,
+}));
+
+vi.mock("@tiptap/react", () => ({
+ useEditor: (options: typeof tiptapState.options) => {
+ tiptapState.options = options;
+ return tiptapState.editor;
+ },
+ EditorContent: ({
+ editor: _editor,
+ ...props
+ }: React.HTMLAttributes<HTMLDivElement> & { editor: Editor | null }) => <div {...props} />,
+}));
+
+vi.mock("@tiptap/starter-kit", () => ({ default: {} }));
+
+vi.mock("@/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: React.ReactNode }) => children,
+}));
+
+vi.mock("@/contexts/I18nContext", () => ({
+ useScopedT: () => (key: string) => {
+ const labels: Record<string, string> = {
+ "tooltips.notesToolbar.play": "Play",
+ "tooltips.notesToolbar.pause": "Pause",
+ "tooltips.notesToolbar.speed": "Scroll speed",
+ "tooltips.notesToolbar.decreaseSpeed": "Decrease scroll speed",
+ "tooltips.notesToolbar.increaseSpeed": "Increase scroll speed",
+ "tooltips.notesToolbar.fontSize": "Font size",
+ "tooltips.notesToolbar.decreaseFontSize": "Decrease font size",
+ "tooltips.notesToolbar.increaseFontSize": "Increase font size",
+ "tooltips.notesToolbar.mirror": "Mirror",
+ };
+ return labels[key] ?? key;
+ },
+}));
+
+function createStorage(): Storage {
+ const values = new Map<string, string>();
+ return {
+ getItem: (key) => values.get(key) ?? null,
+ setItem: (key, value) => values.set(key, String(value)),
+ removeItem: (key) => values.delete(key),
+ clear: () => values.clear(),
+ key: (index) => Array.from(values.keys())[index] ?? null,
+ get length() {
+ return values.size;
+ },
+ };
+}
+
+function createEditor(scrollElement: HTMLElement): Editor {
+ const chain: Record<string, ReturnType<typeof vi.fn>> = {};
+ for (const command of [
+ "focus",
+ "toggleBold",
+ "toggleItalic",
+ "toggleStrike",
+ "toggleBulletList",
+ "toggleOrderedList",
+ "toggleBlockquote",
+ "toggleCodeBlock",
+ ]) {
+ chain[command] = vi.fn(() => chain);
+ }
+ chain.run = vi.fn(() => true);
+
+ return {
+ can: () => ({ chain: () => chain }),
+ chain: () => chain,
+ isActive: () => false,
+ on: vi.fn(),
+ off: vi.fn(),
+ view: { dom: scrollElement },
+ } as unknown as Editor;
+}
+
+describe("NotesWindow teleprompter mode", () => {
+ let scrollElement: HTMLElement;
+ let frameCallbacks: Map<number, FrameRequestCallback>;
+ let nextFrameId: number;
+
+ function flushNextFrame(timestamp: number): void {
+ const entry = frameCallbacks.entries().next().value as
+ | [number, FrameRequestCallback]
+ | undefined;
+ if (!entry) {
+ throw new Error("No animation frame was scheduled");
+ }
+ frameCallbacks.delete(entry[0]);
+ act(() => entry[1](timestamp));
+ }
+
+ beforeEach(() => {
+ Object.defineProperty(globalThis, "localStorage", {
+ value: createStorage(),
+ configurable: true,
+ });
+
+ scrollElement = document.createElement("div");
+ Object.defineProperties(scrollElement, {
+ scrollHeight: { value: 200, configurable: true },
+ clientHeight: { value: 100, configurable: true },
+ });
+ scrollElement.scrollTop = 0;
+ tiptapState.editor = createEditor(scrollElement);
+ tiptapState.options = null;
+
+ frameCallbacks = new Map();
+ nextFrameId = 1;
+ vi.stubGlobal(
+ "requestAnimationFrame",
+ vi.fn((callback: FrameRequestCallback) => {
+ const id = nextFrameId++;
+ frameCallbacks.set(id, callback);
+ return id;
+ }),
+ );
+ vi.stubGlobal(
+ "cancelAnimationFrame",
+ vi.fn((id: number) => {
+ frameCallbacks.delete(id);
+ }),
+ );
+ });
+
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ it("starts paused, scrolls by elapsed time, resets timing on speed changes, and pauses", async () => {
+ const user = userEvent.setup();
+ render(<NotesWindow />);
+
+ await user.click(screen.getByRole("button", { name: "Play" }));
+ expect(screen.getByRole("button", { name: "Pause" })).toBeInTheDocument();
+
+ flushNextFrame(0);
+ expect(scrollElement.scrollTop).toBe(0);
+ flushNextFrame(100);
+ expect(scrollElement.scrollTop).toBe(4);
+
+ await user.click(screen.getByRole("button", { name: "Increase scroll speed" }));
+ flushNextFrame(1_000);
+ expect(scrollElement.scrollTop).toBe(4);
+ flushNextFrame(1_100);
+ expect(scrollElement.scrollTop).toBe(9);
+
+ await user.click(screen.getByRole("button", { name: "Pause" }));
+ expect(screen.getByRole("button", { name: "Play" })).toBeInTheDocument();
+ expect(frameCallbacks.size).toBe(0);
+ });
+
+ it("stops automatically at the bottom", async () => {
+ const user = userEvent.setup();
+ scrollElement.scrollTop = 99;
+ render(<NotesWindow />);
+
+ await user.click(screen.getByRole("button", { name: "Play" }));
+ flushNextFrame(0);
+ flushNextFrame(100);
+
+ expect(scrollElement.scrollTop).toBe(100);
+ expect(screen.getByRole("button", { name: "Play" })).toBeInTheDocument();
+ expect(frameCallbacks.size).toBe(0);
+ });
+
+ it("applies and persists font and mirror settings without persisting playback", async () => {
+ const user = userEvent.setup();
+ render(<NotesWindow />);
+ const content = screen.getByTestId("notes-teleprompter-content");
+
+ expect(content).toHaveStyle({ fontSize: "16px" });
+ expect(content).toHaveAttribute("data-mirrored", "false");
+
+ await user.click(screen.getByRole("button", { name: "Increase font size" }));
+ await user.click(screen.getByRole("button", { name: "Mirror" }));
+ await user.click(screen.getByRole("button", { name: "Play" }));
+
+ expect(content).toHaveStyle({ fontSize: "18px" });
+ expect(content).toHaveAttribute("data-mirrored", "true");
+ await waitFor(() => {
+ expect(JSON.parse(localStorage.getItem(NOTES_TELEPROMPTER_STORAGE_KEY) ?? "")).toEqual({
+ speed: 40,
+ fontSize: 18,
+ mirrored: true,
+ });
+ });
+ });
+
+ it("loads legacy note content and saves editor updates", () => {
+ localStorage.setItem("notes", "First\nSecond");
+ render(<NotesWindow />);
+
+ expect(tiptapState.options?.content).toBe("<p>First</p><p>Second</p>");
+ act(() => {
+ tiptapState.options?.onUpdate({
+ editor: { getHTML: () => "<p>Updated</p>" },
+ });
+ });
+ expect(localStorage.getItem("notes")).toBe("<p>Updated</p>");
+ });
+});
diff --git a/src/components/launch/NotesWindow.tsx b/src/components/launch/NotesWindow.tsx
index 2fb9e29ed..532f50968 100644
--- a/src/components/launch/NotesWindow.tsx
+++ b/src/components/launch/NotesWindow.tsx
@@ -1,27 +1,27 @@
import { EditorContent, useEditor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
+import { useCallback, useEffect, useState } from "react";
import { NotesToolbar } from "./NotesToolbar";
+import {
+ clampNotesFontSize,
+ clampTeleprompterSpeed,
+ getNextTeleprompterScrollTop,
+ getTeleprompterFrame,
+ loadInitialNotesContent,
+ loadNotesTeleprompterSettings,
+ NOTES_FONT_SIZE_STEP,
+ saveNotesContent,
+ saveNotesTeleprompterSettings,
+ TELEPROMPTER_SPEED_STEP,
+} from "./notesTeleprompter";
import "./NotesWindow.module.css";
-function getInitialNotesContent(): string {
- const stored = localStorage.getItem("notes");
- if (!stored) {
- return "";
- }
-
- // Notes saved before Tiptap were plain text; wrap so StarterKit can parse them.
- if (!stored.trim().startsWith("<")) {
- const escaped = stored.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
- return `<p>${escaped.replace(/\n/g, "</p><p>")}</p>`;
- }
-
- return stored;
-}
-
export function NotesWindow() {
+ const [settings, setSettings] = useState(loadNotesTeleprompterSettings);
+ const [isPlaying, setIsPlaying] = useState(false);
const editor = useEditor({
extensions: [StarterKit],
- content: getInitialNotesContent(),
+ content: loadInitialNotesContent(),
autofocus: "end",
editorProps: {
attributes: {
@@ -29,17 +29,98 @@ export function NotesWindow() {
},
},
onUpdate: ({ editor: nextEditor }) => {
- localStorage.setItem("notes", nextEditor.getHTML());
+ saveNotesContent(nextEditor.getHTML());
},
});
+ useEffect(() => {
+ saveNotesTeleprompterSettings(settings);
+ }, [settings]);
+
+ useEffect(() => {
+ if (!isPlaying || !editor) {
+ return;
+ }
+
+ const scrollElement = editor.view.dom;
+ let frameId: number | null = null;
+ let previousTimestamp: number | null = null;
+
+ const tick = (timestamp: number) => {
+ const frame = getTeleprompterFrame(previousTimestamp, timestamp);
+ previousTimestamp = frame.nextTimestamp;
+
+ if (frame.elapsedMs > 0) {
+ const maximumScrollTop = Math.max(
+ 0,
+ scrollElement.scrollHeight - scrollElement.clientHeight,
+ );
+ const nextScrollTop = getNextTeleprompterScrollTop(
+ scrollElement.scrollTop,
+ settings.speed,
+ frame.elapsedMs,
+ maximumScrollTop,
+ );
+ scrollElement.scrollTop = nextScrollTop;
+
+ if (nextScrollTop >= maximumScrollTop) {
+ setIsPlaying(false);
+ return;
+ }
+ }
+
+ frameId = requestAnimationFrame(tick);
+ };
+
+ frameId = requestAnimationFrame(tick);
+ return () => {
+ if (frameId !== null) {
+ cancelAnimationFrame(frameId);
+ }
+ };
+ }, [editor, isPlaying, settings.speed]);
+
+ const changeSpeed = useCallback((delta: number) => {
+ setSettings((current) => ({
+ ...current,
+ speed: clampTeleprompterSpeed(current.speed + delta),
+ }));
+ }, []);
+
+ const changeFontSize = useCallback((delta: number) => {
+ setSettings((current) => ({
+ ...current,
+ fontSize: clampNotesFontSize(current.fontSize + delta),
+ }));
+ }, []);
+
return (
<div className="flex h-screen w-screen flex-col overflow-hidden bg-white px-6 pb-4 pt-3 gap-4">
- <div className="shrink-0 flex justify-center">
- <NotesToolbar editor={editor} />
+ <div className="flex min-w-0 shrink-0 justify-center">
+ <NotesToolbar
+ editor={editor}
+ isPlaying={isPlaying}
+ speed={settings.speed}
+ fontSize={settings.fontSize}
+ mirrored={settings.mirrored}
+ onTogglePlaying={() => setIsPlaying((current) => !current)}
+ onDecreaseSpeed={() => changeSpeed(-TELEPROMPTER_SPEED_STEP)}
+ onIncreaseSpeed={() => changeSpeed(TELEPROMPTER_SPEED_STEP)}
+ onDecreaseFontSize={() => changeFontSize(-NOTES_FONT_SIZE_STEP)}
+ onIncreaseFontSize={() => changeFontSize(NOTES_FONT_SIZE_STEP)}
+ onToggleMirror={() =>
+ setSettings((current) => ({ ...current, mirrored: !current.mirrored }))
+ }
+ />
</div>
- <EditorContent editor={editor} className="min-h-0 flex-1" />
+ <EditorContent
+ editor={editor}
+ data-testid="notes-teleprompter-content"
+ data-mirrored={settings.mirrored}
+ className="notes-teleprompter-content min-h-0 flex-1"
+ style={{ fontSize: `${settings.fontSize}px` }}
+ />
</div>
);
}
diff --git a/src/components/launch/notesTeleprompter.test.ts b/src/components/launch/notesTeleprompter.test.ts
new file mode 100644
index 000000000..ebdb1d328
--- /dev/null
+++ b/src/components/launch/notesTeleprompter.test.ts
@@ -0,0 +1,134 @@
+import { describe, expect, it, vi } from "vitest";
+import {
+ clampNotesFontSize,
+ clampTeleprompterSpeed,
+ DEFAULT_NOTES_TELEPROMPTER_SETTINGS,
+ getNextTeleprompterScrollTop,
+ getTeleprompterFrame,
+ loadInitialNotesContent,
+ loadNotesTeleprompterSettings,
+ MAX_NOTES_FONT_SIZE,
+ MAX_TELEPROMPTER_FRAME_MS,
+ MAX_TELEPROMPTER_SPEED,
+ MIN_NOTES_FONT_SIZE,
+ MIN_TELEPROMPTER_SPEED,
+ NOTES_TELEPROMPTER_STORAGE_KEY,
+ saveNotesContent,
+ saveNotesTeleprompterSettings,
+} from "./notesTeleprompter";
+
+describe("Notes teleprompter settings", () => {
+ it("uses defaults when storage is empty, corrupt, or throws", () => {
+ expect(loadNotesTeleprompterSettings({ getItem: () => null })).toEqual(
+ DEFAULT_NOTES_TELEPROMPTER_SETTINGS,
+ );
+ expect(loadNotesTeleprompterSettings({ getItem: () => "not json" })).toEqual(
+ DEFAULT_NOTES_TELEPROMPTER_SETTINGS,
+ );
+ expect(
+ loadNotesTeleprompterSettings({
+ getItem: () => {
+ throw new Error("denied");
+ },
+ }),
+ ).toEqual(DEFAULT_NOTES_TELEPROMPTER_SETTINGS);
+ });
+
+ it("clamps persisted values and ignores non-setting fields", () => {
+ const stored = JSON.stringify({
+ speed: 1_000,
+ fontSize: 1,
+ mirrored: true,
+ isPlaying: true,
+ });
+ expect(loadNotesTeleprompterSettings({ getItem: () => stored })).toEqual({
+ speed: MAX_TELEPROMPTER_SPEED,
+ fontSize: MIN_NOTES_FONT_SIZE,
+ mirrored: true,
+ });
+ });
+
+ it("round-trips only speed, font size, and mirror", () => {
+ const setItem = vi.fn();
+ expect(
+ saveNotesTeleprompterSettings({ speed: 70, fontSize: 24, mirrored: true }, { setItem }),
+ ).toBe(true);
+ expect(setItem).toHaveBeenCalledWith(
+ NOTES_TELEPROMPTER_STORAGE_KEY,
+ JSON.stringify({ speed: 70, fontSize: 24, mirrored: true }),
+ );
+ });
+
+ it("tolerates storage write failures", () => {
+ expect(
+ saveNotesTeleprompterSettings(DEFAULT_NOTES_TELEPROMPTER_SETTINGS, {
+ setItem: () => {
+ throw new Error("denied");
+ },
+ }),
+ ).toBe(false);
+ });
+
+ it("enforces speed and font-size bounds", () => {
+ expect(clampTeleprompterSpeed(0)).toBe(MIN_TELEPROMPTER_SPEED);
+ expect(clampTeleprompterSpeed(1_000)).toBe(MAX_TELEPROMPTER_SPEED);
+ expect(clampNotesFontSize(0)).toBe(MIN_NOTES_FONT_SIZE);
+ expect(clampNotesFontSize(1_000)).toBe(MAX_NOTES_FONT_SIZE);
+ });
+});
+
+describe("Notes content compatibility", () => {
+ it("preserves HTML and converts escaped legacy plain text", () => {
+ expect(loadInitialNotesContent({ getItem: () => "<p>Saved</p>" })).toBe("<p>Saved</p>");
+ expect(loadInitialNotesContent({ getItem: () => "One & <two>\nThree" })).toBe(
+ "<p>One &amp; &lt;two&gt;</p><p>Three</p>",
+ );
+ });
+
+ it("falls back safely when content storage throws", () => {
+ expect(
+ loadInitialNotesContent({
+ getItem: () => {
+ throw new Error("denied");
+ },
+ }),
+ ).toBe("");
+ expect(
+ saveNotesContent("<p>Saved</p>", {
+ setItem: () => {
+ throw new Error("denied");
+ },
+ }),
+ ).toBe(false);
+ });
+});
+
+describe("Notes teleprompter frame math", () => {
+ it("initializes and resets without moving for invalid or backward timestamps", () => {
+ expect(getTeleprompterFrame(null, 100)).toEqual({
+ elapsedMs: 0,
+ nextTimestamp: 100,
+ });
+ expect(getTeleprompterFrame(100, Number.NaN)).toEqual({
+ elapsedMs: 0,
+ nextTimestamp: null,
+ });
+ expect(getTeleprompterFrame(100, 90)).toEqual({
+ elapsedMs: 0,
+ nextTimestamp: 90,
+ });
+ });
+
+ it("clamps long frame gaps", () => {
+ expect(getTeleprompterFrame(100, 1_000)).toEqual({
+ elapsedMs: MAX_TELEPROMPTER_FRAME_MS,
+ nextTimestamp: 1_000,
+ });
+ });
+
+ it("advances in pixels per second without crossing the bottom", () => {
+ expect(getNextTeleprompterScrollTop(10, 40, 100, 100)).toBe(14);
+ expect(getNextTeleprompterScrollTop(98, 40, 100, 100)).toBe(100);
+ expect(getNextTeleprompterScrollTop(Number.NaN, 40, -1, 100)).toBe(0);
+ });
+});
diff --git a/src/components/launch/notesTeleprompter.ts b/src/components/launch/notesTeleprompter.ts
new file mode 100644
index 000000000..f4b9f8ad2
--- /dev/null
+++ b/src/components/launch/notesTeleprompter.ts
@@ -0,0 +1,167 @@
+export const NOTES_TELEPROMPTER_STORAGE_KEY = "notesTeleprompterSettings";
+
+export const MIN_TELEPROMPTER_SPEED = 10;
+export const MAX_TELEPROMPTER_SPEED = 100;
+export const TELEPROMPTER_SPEED_STEP = 10;
+
+export const MIN_NOTES_FONT_SIZE = 14;
+export const MAX_NOTES_FONT_SIZE = 48;
+export const NOTES_FONT_SIZE_STEP = 2;
+
+export const MAX_TELEPROMPTER_FRAME_MS = 100;
+
+export type NotesTeleprompterSettings = {
+ speed: number;
+ fontSize: number;
+ mirrored: boolean;
+};
+
+export const DEFAULT_NOTES_TELEPROMPTER_SETTINGS: NotesTeleprompterSettings = {
+ speed: 40,
+ fontSize: 16,
+ mirrored: false,
+};
+
+type ReadableStorage = Pick<Storage, "getItem">;
+type WritableStorage = Pick<Storage, "setItem">;
+
+function clampNumber(value: unknown, fallback: number, minimum: number, maximum: number): number {
+ if (typeof value !== "number" || !Number.isFinite(value)) {
+ return fallback;
+ }
+
+ return Math.min(maximum, Math.max(minimum, value));
+}
+
+export function clampTeleprompterSpeed(value: number): number {
+ return clampNumber(
+ value,
+ DEFAULT_NOTES_TELEPROMPTER_SETTINGS.speed,
+ MIN_TELEPROMPTER_SPEED,
+ MAX_TELEPROMPTER_SPEED,
+ );
+}
+
+export function clampNotesFontSize(value: number): number {
+ return clampNumber(
+ value,
+ DEFAULT_NOTES_TELEPROMPTER_SETTINGS.fontSize,
+ MIN_NOTES_FONT_SIZE,
+ MAX_NOTES_FONT_SIZE,
+ );
+}
+
+export function normalizeNotesTeleprompterSettings(value: unknown): NotesTeleprompterSettings {
+ if (!value || typeof value !== "object") {
+ return { ...DEFAULT_NOTES_TELEPROMPTER_SETTINGS };
+ }
+
+ const candidate = value as Partial<NotesTeleprompterSettings>;
+ return {
+ speed: clampTeleprompterSpeed(candidate.speed ?? Number.NaN),
+ fontSize: clampNotesFontSize(candidate.fontSize ?? Number.NaN),
+ mirrored:
+ typeof candidate.mirrored === "boolean"
+ ? candidate.mirrored
+ : DEFAULT_NOTES_TELEPROMPTER_SETTINGS.mirrored,
+ };
+}
+
+export function loadNotesTeleprompterSettings(
+ storage: ReadableStorage = localStorage,
+): NotesTeleprompterSettings {
+ try {
+ const stored = storage.getItem(NOTES_TELEPROMPTER_STORAGE_KEY);
+ return stored
+ ? normalizeNotesTeleprompterSettings(JSON.parse(stored))
+ : { ...DEFAULT_NOTES_TELEPROMPTER_SETTINGS };
+ } catch {
+ return { ...DEFAULT_NOTES_TELEPROMPTER_SETTINGS };
+ }
+}
+
+export function saveNotesTeleprompterSettings(
+ settings: NotesTeleprompterSettings,
+ storage: WritableStorage = localStorage,
+): boolean {
+ try {
+ storage.setItem(
+ NOTES_TELEPROMPTER_STORAGE_KEY,
+ JSON.stringify(normalizeNotesTeleprompterSettings(settings)),
+ );
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+export function loadInitialNotesContent(storage: ReadableStorage = localStorage): string {
+ let stored: string | null;
+ try {
+ stored = storage.getItem("notes");
+ } catch {
+ return "";
+ }
+
+ if (!stored) {
+ return "";
+ }
+
+ // Notes saved before Tiptap were plain text; wrap so StarterKit can parse them.
+ if (!stored.trim().startsWith("<")) {
+ const escaped = stored.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
+ return `<p>${escaped.replace(/\n/g, "</p><p>")}</p>`;
+ }
+
+ return stored;
+}
+
+export function saveNotesContent(html: string, storage: WritableStorage = localStorage): boolean {
+ try {
+ storage.setItem("notes", html);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+export type TeleprompterFrame = {
+ elapsedMs: number;
+ nextTimestamp: number | null;
+};
+
+export function getTeleprompterFrame(
+ previousTimestamp: number | null,
+ currentTimestamp: number,
+): TeleprompterFrame {
+ if (!Number.isFinite(currentTimestamp)) {
+ return { elapsedMs: 0, nextTimestamp: null };
+ }
+
+ if (
+ previousTimestamp === null ||
+ !Number.isFinite(previousTimestamp) ||
+ currentTimestamp <= previousTimestamp
+ ) {
+ return { elapsedMs: 0, nextTimestamp: currentTimestamp };
+ }
+
+ return {
+ elapsedMs: Math.min(currentTimestamp - previousTimestamp, MAX_TELEPROMPTER_FRAME_MS),
+ nextTimestamp: currentTimestamp,
+ };
+}
+
+export function getNextTeleprompterScrollTop(
+ currentScrollTop: number,
+ speed: number,
+ elapsedMs: number,
+ maxScrollTop: number,
+): number {
+ const safeCurrent = Number.isFinite(currentScrollTop) ? Math.max(0, currentScrollTop) : 0;
+ const safeMaximum = Number.isFinite(maxScrollTop) ? Math.max(0, maxScrollTop) : 0;
+ const safeElapsed = Number.isFinite(elapsedMs) ? Math.max(0, elapsedMs) : 0;
+ const distance = (clampTeleprompterSpeed(speed) * safeElapsed) / 1_000;
+
+ return Math.min(safeMaximum, safeCurrent + distance);
+}
diff --git a/src/i18n/locales/ar/launch.json b/src/i18n/locales/ar/launch.json
index 37b1a4fb5..08cb8a4e5 100644
--- a/src/i18n/locales/ar/launch.json
+++ b/src/i18n/locales/ar/launch.json
@@ -20,7 +20,16 @@
"bulletList": "قائمة نقطية",
"numberedList": "قائمة مرقمة",
"blockquote": "اقتباس",
- "codeBlock": "كتلة تعليمات برمجية"
+ "codeBlock": "كتلة تعليمات برمجية",
+ "play": "تشغيل التمرير التلقائي",
+ "pause": "إيقاف التمرير مؤقتًا",
+ "speed": "سرعة التمرير",
+ "decreaseSpeed": "تقليل سرعة التمرير",
+ "increaseSpeed": "زيادة سرعة التمرير",
+ "fontSize": "حجم الخط",
+ "decreaseFontSize": "تصغير حجم الخط",
+ "increaseFontSize": "تكبير حجم الخط",
+ "mirror": "عكس أفقي"
}
},
"audio": {
diff --git a/src/i18n/locales/en/launch.json b/src/i18n/locales/en/launch.json
index 95039a859..02b8ca626 100644
--- a/src/i18n/locales/en/launch.json
+++ b/src/i18n/locales/en/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Bullet list",
"numberedList": "Numbered list",
"blockquote": "Blockquote",
- "codeBlock": "Code block"
+ "codeBlock": "Code block",
+ "play": "Start auto-scroll",
+ "pause": "Pause auto-scroll",
+ "speed": "Scroll speed",
+ "decreaseSpeed": "Decrease scroll speed",
+ "increaseSpeed": "Increase scroll speed",
+ "fontSize": "Font size",
+ "decreaseFontSize": "Decrease font size",
+ "increaseFontSize": "Increase font size",
+ "mirror": "Mirror horizontally"
}
},
"audio": {
diff --git a/src/i18n/locales/es/launch.json b/src/i18n/locales/es/launch.json
index a37123894..c5fb8d10e 100644
--- a/src/i18n/locales/es/launch.json
+++ b/src/i18n/locales/es/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Lista con viñetas",
"numberedList": "Lista numerada",
"blockquote": "Cita",
- "codeBlock": "Bloque de código"
+ "codeBlock": "Bloque de código",
+ "play": "Iniciar desplazamiento automático",
+ "pause": "Pausar desplazamiento automático",
+ "speed": "Velocidad de desplazamiento",
+ "decreaseSpeed": "Reducir velocidad de desplazamiento",
+ "increaseSpeed": "Aumentar velocidad de desplazamiento",
+ "fontSize": "Tamaño de fuente",
+ "decreaseFontSize": "Reducir tamaño de fuente",
+ "increaseFontSize": "Aumentar tamaño de fuente",
+ "mirror": "Reflejar horizontalmente"
}
},
"audio": {
diff --git a/src/i18n/locales/fr/launch.json b/src/i18n/locales/fr/launch.json
index 929a8c8db..5c49eafd1 100644
--- a/src/i18n/locales/fr/launch.json
+++ b/src/i18n/locales/fr/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Liste à puces",
"numberedList": "Liste numérotée",
"blockquote": "Citation",
- "codeBlock": "Bloc de code"
+ "codeBlock": "Bloc de code",
+ "play": "Démarrer le défilement automatique",
+ "pause": "Mettre le défilement en pause",
+ "speed": "Vitesse de défilement",
+ "decreaseSpeed": "Réduire la vitesse de défilement",
+ "increaseSpeed": "Augmenter la vitesse de défilement",
+ "fontSize": "Taille de police",
+ "decreaseFontSize": "Réduire la taille de police",
+ "increaseFontSize": "Augmenter la taille de police",
+ "mirror": "Miroir horizontal"
}
},
"audio": {
diff --git a/src/i18n/locales/it/launch.json b/src/i18n/locales/it/launch.json
index 89eb8c9e5..7136316a1 100644
--- a/src/i18n/locales/it/launch.json
+++ b/src/i18n/locales/it/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Elenco puntato",
"numberedList": "Elenco numerato",
"blockquote": "Citazione",
- "codeBlock": "Blocco di codice"
+ "codeBlock": "Blocco di codice",
+ "play": "Avvia scorrimento automatico",
+ "pause": "Metti in pausa lo scorrimento",
+ "speed": "Velocità di scorrimento",
+ "decreaseSpeed": "Riduci velocità di scorrimento",
+ "increaseSpeed": "Aumenta velocità di scorrimento",
+ "fontSize": "Dimensione carattere",
+ "decreaseFontSize": "Riduci dimensione carattere",
+ "increaseFontSize": "Aumenta dimensione carattere",
+ "mirror": "Specchia orizzontalmente"
}
},
"audio": {
diff --git a/src/i18n/locales/ja-JP/launch.json b/src/i18n/locales/ja-JP/launch.json
index 08d4b2349..bb564e44b 100644
--- a/src/i18n/locales/ja-JP/launch.json
+++ b/src/i18n/locales/ja-JP/launch.json
@@ -20,7 +20,16 @@
"bulletList": "箇条書きリスト",
"numberedList": "番号付きリスト",
"blockquote": "引用",
- "codeBlock": "コードブロック"
+ "codeBlock": "コードブロック",
+ "play": "自動スクロールを開始",
+ "pause": "自動スクロールを一時停止",
+ "speed": "スクロール速度",
+ "decreaseSpeed": "スクロール速度を下げる",
+ "increaseSpeed": "スクロール速度を上げる",
+ "fontSize": "フォントサイズ",
+ "decreaseFontSize": "フォントサイズを小さくする",
+ "increaseFontSize": "フォントサイズを大きくする",
+ "mirror": "左右反転"
}
},
"audio": {
diff --git a/src/i18n/locales/ko-KR/launch.json b/src/i18n/locales/ko-KR/launch.json
index 00c0c3625..bd297c0c7 100644
--- a/src/i18n/locales/ko-KR/launch.json
+++ b/src/i18n/locales/ko-KR/launch.json
@@ -20,7 +20,16 @@
"bulletList": "글머리 기호 목록",
"numberedList": "번호 매기기 목록",
"blockquote": "인용문",
- "codeBlock": "코드 블록"
+ "codeBlock": "코드 블록",
+ "play": "자동 스크롤 시작",
+ "pause": "자동 스크롤 일시 중지",
+ "speed": "스크롤 속도",
+ "decreaseSpeed": "스크롤 속도 낮추기",
+ "increaseSpeed": "스크롤 속도 높이기",
+ "fontSize": "글꼴 크기",
+ "decreaseFontSize": "글꼴 크기 줄이기",
+ "increaseFontSize": "글꼴 크기 늘리기",
+ "mirror": "좌우 반전"
}
},
"audio": {
diff --git a/src/i18n/locales/pt-BR/launch.json b/src/i18n/locales/pt-BR/launch.json
index 97733fb6e..1470d4cce 100644
--- a/src/i18n/locales/pt-BR/launch.json
+++ b/src/i18n/locales/pt-BR/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Lista com marcadores",
"numberedList": "Lista numerada",
"blockquote": "Citação",
- "codeBlock": "Bloco de código"
+ "codeBlock": "Bloco de código",
+ "play": "Iniciar rolagem automática",
+ "pause": "Pausar rolagem automática",
+ "speed": "Velocidade de rolagem",
+ "decreaseSpeed": "Diminuir velocidade de rolagem",
+ "increaseSpeed": "Aumentar velocidade de rolagem",
+ "fontSize": "Tamanho da fonte",
+ "decreaseFontSize": "Diminuir tamanho da fonte",
+ "increaseFontSize": "Aumentar tamanho da fonte",
+ "mirror": "Espelhar horizontalmente"
}
},
"audio": {
diff --git a/src/i18n/locales/ru/launch.json b/src/i18n/locales/ru/launch.json
index d9cddeaf1..7836e4b87 100644
--- a/src/i18n/locales/ru/launch.json
+++ b/src/i18n/locales/ru/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Маркированный список",
"numberedList": "Нумерованный список",
"blockquote": "Цитата",
- "codeBlock": "Блок кода"
+ "codeBlock": "Блок кода",
+ "play": "Запустить автопрокрутку",
+ "pause": "Приостановить автопрокрутку",
+ "speed": "Скорость прокрутки",
+ "decreaseSpeed": "Уменьшить скорость прокрутки",
+ "increaseSpeed": "Увеличить скорость прокрутки",
+ "fontSize": "Размер шрифта",
+ "decreaseFontSize": "Уменьшить размер шрифта",
+ "increaseFontSize": "Увеличить размер шрифта",
+ "mirror": "Отразить по горизонтали"
}
},
"audio": {
diff --git a/src/i18n/locales/tr/launch.json b/src/i18n/locales/tr/launch.json
index e1d6593a3..05e415afb 100644
--- a/src/i18n/locales/tr/launch.json
+++ b/src/i18n/locales/tr/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Madde işaretli liste",
"numberedList": "Numaralı liste",
"blockquote": "Alıntı",
- "codeBlock": "Kod bloğu"
+ "codeBlock": "Kod bloğu",
+ "play": "Otomatik kaydırmayı başlat",
+ "pause": "Otomatik kaydırmayı duraklat",
+ "speed": "Kaydırma hızı",
+ "decreaseSpeed": "Kaydırma hızını azalt",
+ "increaseSpeed": "Kaydırma hızını artır",
+ "fontSize": "Yazı tipi boyutu",
+ "decreaseFontSize": "Yazı tipi boyutunu küçült",
+ "increaseFontSize": "Yazı tipi boyutunu büyüt",
+ "mirror": "Yatay aynala"
}
},
"audio": {
diff --git a/src/i18n/locales/vi/launch.json b/src/i18n/locales/vi/launch.json
index 70bbdd42c..e1488e425 100644
--- a/src/i18n/locales/vi/launch.json
+++ b/src/i18n/locales/vi/launch.json
@@ -20,7 +20,16 @@
"bulletList": "Danh sách dấu đầu dòng",
"numberedList": "Danh sách đánh số",
"blockquote": "Trích dẫn",
- "codeBlock": "Khối mã"
+ "codeBlock": "Khối mã",
+ "play": "Bắt đầu tự động cuộn",
+ "pause": "Tạm dừng tự động cuộn",
+ "speed": "Tốc độ cuộn",
+ "decreaseSpeed": "Giảm tốc độ cuộn",
+ "increaseSpeed": "Tăng tốc độ cuộn",
+ "fontSize": "Cỡ chữ",
+ "decreaseFontSize": "Giảm cỡ chữ",
+ "increaseFontSize": "Tăng cỡ chữ",
+ "mirror": "Lật ngang"
}
},
"audio": {
diff --git a/src/i18n/locales/zh-CN/launch.json b/src/i18n/locales/zh-CN/launch.json
index 232c3568e..f67815fce 100644
--- a/src/i18n/locales/zh-CN/launch.json
+++ b/src/i18n/locales/zh-CN/launch.json
@@ -20,7 +20,16 @@
"bulletList": "无序列表",
"numberedList": "有序列表",
"blockquote": "引用",
- "codeBlock": "代码块"
+ "codeBlock": "代码块",
+ "play": "开始自动滚动",
+ "pause": "暂停自动滚动",
+ "speed": "滚动速度",
+ "decreaseSpeed": "降低滚动速度",
+ "increaseSpeed": "提高滚动速度",
+ "fontSize": "字体大小",
+ "decreaseFontSize": "减小字体",
+ "increaseFontSize": "增大字体",
+ "mirror": "水平镜像"
}
},
"audio": {
diff --git a/src/i18n/locales/zh-TW/launch.json b/src/i18n/locales/zh-TW/launch.json
index 73d8a99c5..5e8fbf10d 100644
--- a/src/i18n/locales/zh-TW/launch.json
+++ b/src/i18n/locales/zh-TW/launch.json
@@ -20,7 +20,16 @@
"bulletList": "項目符號清單",
"numberedList": "編號清單",
"blockquote": "引言",
- "codeBlock": "程式碼區塊"
+ "codeBlock": "程式碼區塊",
+ "play": "開始自動捲動",
+ "pause": "暫停自動捲動",
+ "speed": "捲動速度",
+ "decreaseSpeed": "降低捲動速度",
+ "increaseSpeed": "提高捲動速度",
+ "fontSize": "字體大小",
+ "decreaseFontSize": "縮小字體",
+ "increaseFontSize": "放大字體",
+ "mirror": "水平鏡像"
}
},
"audio": {