diff options
author | Aleksander Machniak <alec@alec.pl> | 2020-02-23 14:59:14 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2020-03-01 12:57:24 +0300 |
commit | 1c5f83d41cccefa3e54ae2c752a534fe51136a64 (patch) | |
tree | d4cd5199df80b526cf5f095494b3e04ba3ddb36b /skins | |
parent | 233beea354e5986bc9496ca7a8b9eefcee609e19 (diff) |
Elastic: Fix text selection with Shift+PageUp and Shift+PageDown in plain text editor when using Chrome (#7230)
Diffstat (limited to 'skins')
-rw-r--r-- | skins/elastic/styles/widgets/editor.less | 1 | ||||
-rw-r--r-- | skins/elastic/ui.js | 41 |
2 files changed, 13 insertions, 29 deletions
diff --git a/skins/elastic/styles/widgets/editor.less b/skins/elastic/styles/widgets/editor.less index 5e602c13f..57e621434 100644 --- a/skins/elastic/styles/widgets/editor.less +++ b/skins/elastic/styles/widgets/editor.less @@ -898,6 +898,7 @@ html.touch .mce-grid td { font-family: monospace; width: 100% !important; padding-top: 2.5rem; + resize: none; } & > iframe { // e.g. mailvelope frame diff --git a/skins/elastic/ui.js b/skins/elastic/ui.js index 13f205025..606cfbaa2 100644 --- a/skins/elastic/ui.js +++ b/skins/elastic/ui.js @@ -3741,37 +3741,20 @@ function rcube_elastic_ui() */ function textarea_autoresize_init(textarea) { - var resize = function(e) { - clearTimeout(env.textarea_timer); - env.textarea_timer = setTimeout(function() { - var area = $(e.target), - initial_height = area.data('initial-height'), - scroll_height = area[0].scrollHeight; - - // do nothing when the area is hidden - if (!scroll_height) { - return; - } - - if (!initial_height) { - area.data('initial-height', initial_height = scroll_height); - } - - // strange effect in Chrome/Firefox when you delete a line in the textarea - // the scrollHeight is not decreased by the line height, but by 2px - // so jumps up many times in small steps, we'd rather use one big step - if (area.outerHeight() - scroll_height == 2) { - scroll_height -= 19; // 21px is the assumed line height + // FIXME: Is there a better way to get initial height of the textarea? + var min_height = ($(textarea)[0].rows || 5) * 21, + resize = function(e) { + var oldHeight = $(this).outerHeight(); + $(this).outerHeight(0); + var newHeight = Math.max(min_height, this.scrollHeight); + $(this).outerHeight(oldHeight); + + if (newHeight !== oldHeight) { + $(this).height(newHeight); } + }; - area.outerHeight(Math.max(initial_height, scroll_height)); - }, 10); - }; - - $(textarea).css('overflow-y', 'hidden').on('input', resize).trigger('input'); - - // Make sure the height is up-to-date also in time intervals - setInterval(function() { $(textarea).trigger('input'); }, 1000); + $(textarea).on('input', resize).trigger('input'); }; // Inititalizes smart list input |