Skip to content
Snippets Groups Projects
Commit d03c59b7 authored by Stanislas Rolland's avatar Stanislas Rolland Committed by Andreas Fernandez
Browse files

[BUGFIX] Automatic scrolling of editing form when inserting paragraph

Problem: Entering a new paragraph leads to automatic scrolling of the
editing form in the backend if the cursor is positioned in the last
line of the visible editing area of the RTE.
Solution: Scroll only the iframe window if the caret is not into view.

Releases: master, 6.2
Resolves: #22167
Change-Id: I731e95931ac303f7ab2d7e493ba87d9788a51251
Reviewed-on: http://review.typo3.org/37894


Reviewed-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Tested-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Reviewed-by: default avatarAndreas Fernandez <andreas.fernandez@aspedia.de>
Tested-by: default avatarAndreas Fernandez <andreas.fernandez@aspedia.de>
parent 0500220a
Branches
Tags
No related merge requests found
......@@ -517,13 +517,18 @@ define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Editor/Editor',
*/
Editor.prototype.scrollToCaret = function () {
if (!UserAgent.isIE) {
var e = this.getSelection().getParentElement(),
w = this.iframe.getEl().contentWindow ? this.iframe.getEl().contentWindow : window,
h = w.innerHeight || w.height,
d = this.document,
t = d.documentElement.scrollTop || d.body.scrollTop;
if (e.offsetTop > h+t || e.offsetTop < t) {
this.getSelection().getParentElement().scrollIntoView();
var contentWindow = this.iframe.getEl().contentWindow;
if (contentWindow) {
var windowHeight = contentWindow.innerHeight,
element = this.getSelection().getParentElement(),
elementOffset = element.offsetTop,
elementHeight = Dom.getSize(element).height,
bodyScrollTop = contentWindow.document.body.scrollTop;
// If the current selection is out of view
if (elementOffset > windowHeight + bodyScrollTop || elementOffset < bodyScrollTop) {
// Scroll the iframe contentWindow
contentWindow.scrollTo(0, elementOffset - windowHeight + elementHeight);
}
}
}
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment