Skip to content

Commit

Permalink
Markdown Editor: Fixed scroll jump on image upload
Browse files Browse the repository at this point in the history
For #5384
  • Loading branch information
ssddanbrown committed Jan 4, 2025
1 parent 980a684 commit ff6c5aa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions resources/js/markdown/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

/**
Expand Down

0 comments on commit ff6c5aa

Please sign in to comment.