From: Dan Brown Date: Sat, 4 Jan 2025 21:01:28 +0000 (+0000) Subject: Markdown Editor: Fixed scroll jump on image upload X-Git-Tag: v24.12.1~1^2~3 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/ff6c5aaecbd470204136e8368eeed69d38d05d15 Markdown Editor: Fixed scroll jump on image upload For #5384 --- diff --git a/resources/js/markdown/actions.js b/resources/js/markdown/actions.js index 86e255328..e99bbf3e1 100644 --- a/resources/js/markdown/actions.js +++ b/resources/js/markdown/actions.js @@ -445,8 +445,12 @@ export class Actions { selectionRange = selectionRange || this.#getSelectionRange(); const newDoc = this.editor.cm.state.toText(text); const newSelectFrom = Math.min(selectionRange.from, newDoc.length); + const scrollTop = this.editor.cm.scrollDOM.scrollTop; this.#dispatchChange(0, this.editor.cm.state.doc.length, text, newSelectFrom); this.focus(); + window.requestAnimationFrame(() => { + this.editor.cm.scrollDOM.scrollTop = scrollTop; + }); } /**