]> BookStack Code Mirror - bookstack/commitdiff
Markdown Editor: Fixed scroll jump on image upload
authorDan Brown <redacted>
Sat, 4 Jan 2025 21:01:28 +0000 (21:01 +0000)
committerDan Brown <redacted>
Sat, 4 Jan 2025 21:01:28 +0000 (21:01 +0000)
For #5384

resources/js/markdown/actions.js

index 86e25532802384f471bf6896f7d2c8f845a844f1..e99bbf3e14fe5cb668e2e7c22782c0cf0ce44508 100644 (file)
@@ -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;
+        });
     }
 
     /**
Morty Proxy This is a proxified and sanitized view of the page, visit original site.