Skip to content

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

fix(notes): create the editor read-only when a restored mirror locks it

My-Denia3ccb88babe7c
diff --git a/src/components/launch/NotesWindow.test.tsx b/src/components/launch/NotesWindow.test.tsx
index 44ff92454..87989c452 100644
--- a/src/components/launch/NotesWindow.test.tsx
+++ b/src/components/launch/NotesWindow.test.tsx
@@ -10,6 +10,7 @@ import { NOTES_TELEPROMPTER_STORAGE_KEY } from "./notesTeleprompter";
const tiptapState = vi.hoisted(() => ({
options: null as null | {
content: string;
+ editable: boolean;
onUpdate: (payload: { editor: { getHTML: () => string } }) => void;
},
editor: null as Editor | null,
@@ -311,6 +312,9 @@ describe("NotesWindow teleprompter mode", () => {
);
render(<NotesWindow />);
+ // The editor must be CREATED read-only — an effect-only lock would leave the first
+ // painted frame editable.
+ expect(tiptapState.options?.editable).toBe(false);
expect(setEditable).toHaveBeenLastCalledWith(false, false);
expect(setEditable).not.toHaveBeenCalledWith(true, false);
expect(screen.getByRole("button", { name: "Bold" })).toBeDisabled();
@@ -318,6 +322,11 @@ describe("NotesWindow teleprompter mode", () => {
expect(screen.getByRole("button", { name: "Play" })).toBeInTheDocument();
});
+ it("creates the editor editable when nothing locks it at mount", () => {
+ render(<NotesWindow />);
+ expect(tiptapState.options?.editable).toBe(true);
+ });
+
it("keeps mirroring and playback independent", async () => {
const user = userEvent.setup();
render(<NotesWindow />);
diff --git a/src/components/launch/NotesWindow.tsx b/src/components/launch/NotesWindow.tsx
index b16c3a168..cf5819ae9 100644
--- a/src/components/launch/NotesWindow.tsx
+++ b/src/components/launch/NotesWindow.tsx
@@ -23,10 +23,21 @@ export function NotesWindow() {
const [settings, setSettings] = useState(loadNotesTeleprompterSettings);
const [isPlaying, setIsPlaying] = useState(false);
const [initialContent] = useState(loadInitialNotesContent);
+
+ // Whether the note body currently rejects edits. Playback locks it because typing makes
+ // ProseMirror scroll the caret back into view, which fights the teleprompter. Mirroring
+ // locks it because caret placement and selection are horizontally reversed on screen, so
+ // the mirrored note is presentation-only. The teleprompter controls themselves stay live
+ // in both states; turning the lock's last reason off restores editing.
+ const editingLocked = isPlaying || settings.mirrored;
+
const editor = useEditor({
extensions: [StarterKit],
content: initialContent,
autofocus: "end",
+ // A restored mirror must lock the note from the very first paint — an effect runs
+ // only after the first commit, which would leave one editable frame.
+ editable: !editingLocked,
editorProps: {
attributes: {
class: "tiptap",
@@ -49,13 +60,6 @@ export function NotesWindow() {
saveNotesTeleprompterSettings(settings);
}, [settings]);
- // Whether the note body currently rejects edits. Playback locks it because typing makes
- // ProseMirror scroll the caret back into view, which fights the teleprompter. Mirroring
- // locks it because caret placement and selection are horizontally reversed on screen, so
- // the mirrored note is presentation-only. The teleprompter controls themselves stay live
- // in both states; turning the lock's last reason off restores editing.
- const editingLocked = isPlaying || settings.mirrored;
-
// `emitUpdate: false` — the content did not change, so there is nothing to persist.
useEffect(() => {
editor?.setEditable(!editingLocked, false);