diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx index 86ca3636f9..fa0878a5b0 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx @@ -167,7 +167,9 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { const historyDebugSettings = useRef( undefined, ); - // The editor reads these once, so changing them recreates it. + // BlockNote reads this object each time it shows a version, so a change + // applies without creating the editor again (which would lose the selection). + const [experimentalOptions] = useState(() => ({})); const [experimentalDiffs, setExperimentalDiffs] = useState({}); const historyDefaults = { @@ -291,7 +293,7 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { return cursorElement; }, showCursorLabels: showCursorLabels as 'always' | 'activity', - experimental: experimentalDiffs, + experimental: experimentalOptions, }, dropCursor: { color: 'var(--c--contextuals--background--semantic--brand--tertiary)', @@ -389,7 +391,7 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { aiExtension, cursorName, docUserStore, - experimentalDiffs, + experimentalOptions, langLocalesBN, langLocalesBNMultiColumn, langLocalesBNAI, @@ -475,7 +477,20 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { initialSettings: historyDebugSettings.current ?? historyDefaults, canCreate: !!doc.abilities.partial_update, experimental: experimentalDiffs, - onExperimentalChange: setExperimentalDiffs, + onExperimentalChange: (experimental) => { + experimentalOptions.versionDiffFixes = + experimental.versionDiffFixes; + setExperimentalDiffs(experimental); + // Show the selected versions again with the new setting. + const mode = + editor.getExtension('versioning'); + const state = mode?.store.state; + if (mode && state?.mode === 'versions') { + void mode.select(state.displayed, { + compareTo: state.compareTo, + }); + } + }, onApply: async (settings) => { historyDebugSettings.current = settings; const mode = diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/VersionHistoryDebug.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/VersionHistoryDebug.tsx index e404d46ee7..a2af199c06 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/VersionHistoryDebug.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/VersionHistoryDebug.tsx @@ -384,7 +384,9 @@ export const VersionHistoryDebug = ({ ))} - {t('Experimental. Changing this reloads the editor.')} + {t( + 'Experimental. Changing this shows the selected versions again.', + )}