diff --git a/apps/studio/src/editor/EditorToolbar.tsx b/apps/studio/src/editor/EditorToolbar.tsx index 32def97..a51ca99 100644 --- a/apps/studio/src/editor/EditorToolbar.tsx +++ b/apps/studio/src/editor/EditorToolbar.tsx @@ -168,8 +168,8 @@ export function EditorToolbar({ } function insertFileLink(currentEditor: Editor) { - let path = ""; - let filename = "Document"; + let path: string; + let filename: string; if (latestUpload?.kind === "pdf") { path = latestUpload.publicPath; diff --git a/apps/studio/src/editor/SourceDraftEditor.tsx b/apps/studio/src/editor/SourceDraftEditor.tsx index f3e2e00..6c703d6 100644 --- a/apps/studio/src/editor/SourceDraftEditor.tsx +++ b/apps/studio/src/editor/SourceDraftEditor.tsx @@ -72,6 +72,10 @@ export function SourceDraftEditor({ const bodyVersion = useRef(body); const slashHandlerRef = useRef<(command: SlashCommandId) => void>(() => {}); + // Build the slash extension once and dispatch to the latest handler through + // slashHandlerRef, so the Tiptap extension is not rebuilt on every render. + // The React Compiler flags this intentional latest-ref pattern. + /* eslint-disable react-hooks/preserve-manual-memoization, react-hooks/refs */ const slashExtension = useMemo( () => createSlashCommandsExtension( @@ -109,6 +113,7 @@ export function SourceDraftEditor({ ), [], ); + /* eslint-enable react-hooks/preserve-manual-memoization, react-hooks/refs */ const editor = useEditor({ extensions: [