diff options
Diffstat (limited to 'subprojects/frontend/src/editor/EditorStore.ts')
-rw-r--r-- | subprojects/frontend/src/editor/EditorStore.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/subprojects/frontend/src/editor/EditorStore.ts b/subprojects/frontend/src/editor/EditorStore.ts index f128d70d..d0b580ed 100644 --- a/subprojects/frontend/src/editor/EditorStore.ts +++ b/subprojects/frontend/src/editor/EditorStore.ts | |||
@@ -218,9 +218,21 @@ export default class EditorStore { | |||
218 | contentDOM.removeAttribute('aria-expanded'); | 218 | contentDOM.removeAttribute('aria-expanded'); |
219 | contentDOM.setAttribute('aria-label', 'Code editor'); | 219 | contentDOM.setAttribute('aria-label', 'Code editor'); |
220 | 220 | ||
221 | this.scrollToTop(); | ||
222 | |||
221 | log.info('Editor created'); | 223 | log.info('Editor created'); |
222 | } | 224 | } |
223 | 225 | ||
226 | private scrollToTop() { | ||
227 | if (this.view === undefined) { | ||
228 | return; | ||
229 | } | ||
230 | const { | ||
231 | view: { scrollDOM }, | ||
232 | } = this; | ||
233 | scrollDOM.scrollTo({ top: 0, left: 0, behavior: 'instant' }); | ||
234 | } | ||
235 | |||
224 | dispatch(...specs: readonly TransactionSpec[]): void { | 236 | dispatch(...specs: readonly TransactionSpec[]): void { |
225 | const transaction = this.state.update(...specs); | 237 | const transaction = this.state.update(...specs); |
226 | this.dispatchTransaction(transaction); | 238 | this.dispatchTransaction(transaction); |
@@ -476,6 +488,7 @@ export default class EditorStore { | |||
476 | ], | 488 | ], |
477 | effects: [historyCompartment.reconfigure([])], | 489 | effects: [historyCompartment.reconfigure([])], |
478 | }); | 490 | }); |
491 | this.scrollToTop(); | ||
479 | // Clear history by removing and re-adding the history extension. See | 492 | // Clear history by removing and re-adding the history extension. See |
480 | // https://stackoverflow.com/a/77943295 and | 493 | // https://stackoverflow.com/a/77943295 and |
481 | // https://discuss.codemirror.net/t/codemirror-6-cm-clearhistory-equivalent/2851/10 | 494 | // https://discuss.codemirror.net/t/codemirror-6-cm-clearhistory-equivalent/2851/10 |