From 63b2064420c148653502db987e92b2f9353692be Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Fri, 14 Apr 2023 09:59:31 +0100 Subject: [PATCH] [cm6] Add scrollIntoView when commands are dispatched (#11678) GitOrigin-RevId: be005885330b9b29c7ddbfeacaec0a41d96e5e25 --- .../js/features/source-editor/commands/ranges.ts | 6 ++++-- .../features/source-editor/extensions/toolbar/lists.ts | 9 ++++++--- .../source-editor/extensions/toolbar/sections.ts | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/services/web/frontend/js/features/source-editor/commands/ranges.ts b/services/web/frontend/js/features/source-editor/commands/ranges.ts index 5c5318c017..7bfa401e4d 100644 --- a/services/web/frontend/js/features/source-editor/commands/ranges.ts +++ b/services/web/frontend/js/features/source-editor/commands/ranges.ts @@ -67,7 +67,8 @@ export const wrapRanges = }, ], } - }) + }), + { scrollIntoView: true } ) return true } @@ -753,7 +754,8 @@ export function toggleRanges(command: string) { // Shouldn't happen, but default to just wrapping the content return wrapRangeInCommand(view.state, range, command) - }) + }), + { scrollIntoView: true } ) return true } diff --git a/services/web/frontend/js/features/source-editor/extensions/toolbar/lists.ts b/services/web/frontend/js/features/source-editor/extensions/toolbar/lists.ts index 7f848c3557..f1cd9e2986 100644 --- a/services/web/frontend/js/features/source-editor/extensions/toolbar/lists.ts +++ b/services/web/frontend/js/features/source-editor/extensions/toolbar/lists.ts @@ -87,7 +87,8 @@ const wrapRangesInList = view.dispatch( view.state.changeByRange(range => wrapRangeInList(view.state, range, environment) - ) + ), + { scrollIntoView: true } ) return true } @@ -182,7 +183,8 @@ const unwrapRangesFromList = view.dispatch( view.state.changeByRange(range => unwrapRangeFromList(view.state, range, environment) - ) + ), + { scrollIntoView: true } ) return true } @@ -306,7 +308,8 @@ export const toggleListForRanges = view.dispatch( view.state.changeByRange(range => toggleListForRange(view, range, environment) - ) + ), + { scrollIntoView: true } ) } diff --git a/services/web/frontend/js/features/source-editor/extensions/toolbar/sections.ts b/services/web/frontend/js/features/source-editor/extensions/toolbar/sections.ts index 54817f3aa4..140869c1e7 100644 --- a/services/web/frontend/js/features/source-editor/extensions/toolbar/sections.ts +++ b/services/web/frontend/js/features/source-editor/extensions/toolbar/sections.ts @@ -134,6 +134,7 @@ export const setSectionHeadingLevel = (view: EditorView, level: string) => { changes, } } - }) + }), + { scrollIntoView: true } ) }