mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐛 Fixed scroll jump in editor when pasting a url onto a selection to create a link
closes https://github.com/TryGhost/Ghost/issues/10090 - when mobiledoc-kit replaces the selection the caret window selection is temporarily set to the whole editor element which was causing our scroll-cursor-into-view routine to scroll incorrectly - adding the guard allows the first replacement cursor change to be ignored but the second cursor change to be picked up which will do nothing if the text is on-screen, or scroll if it's off screen as normal
This commit is contained in:
parent
f021badb9f
commit
98e0f66c59
1 changed files with 10 additions and 0 deletions
|
@ -1228,6 +1228,16 @@ export default Component.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
// start/endContainer matching editor element means the window range is
|
||||
// outside of a text element so we don't want to scroll incorrectly
|
||||
// (happens when replacing a selection with a link on paste)
|
||||
if (windowRange &&
|
||||
windowRange.startContainer === this.editor.element &&
|
||||
windowRange.endContainer === this.editor.element
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (windowRange) {
|
||||
// cursorTop is relative to the window rather than document or scroll container
|
||||
let {top: cursorTop, height: cursorHeight} = windowRange.getBoundingClientRect();
|
||||
|
|
Loading…
Add table
Reference in a new issue