From 6ace2c1fbc88914117b8261f4a7c461f9db09659 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 5 Jul 2023 11:23:28 -0600 Subject: [PATCH] Mail: Let browser deal with text area sizing in compose Fixes bug where toolbar can get hidden when editing certain emails --- mail/js/app.js | 84 +++--------------- mail/templates/default/compose.xet | 137 +++++++++++++++-------------- 2 files changed, 87 insertions(+), 134 deletions(-) diff --git a/mail/js/app.js b/mail/js/app.js index a339af68a3..471b1ae912 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -363,16 +363,23 @@ app.classes.mail = AppJS.extend( that.compose_fieldExpander(); } }); - /*Trigger compose_resizeHandler after the TinyMCE is fully loaded*/ + /*Trigger after the TinyMCE is fully loaded*/ jQuery('#mail-compose').on ('load',function() { if (textAreaWidget && textAreaWidget.tinymce) { - textAreaWidget.tinymce.then(()=>{ - that.compose_resizeHandler(); - if (textAreaWidget.editor) jQuery(textAreaWidget.editor.iframeElement.contentWindow.document).on('dragenter', function(){ - // anything to bind on tinymce iframe - }); + textAreaWidget.tinymce.then(()=> + { + // Clear explicit height so browser can manage it + textAreaWidget.tinymce_container.style.height = ""; + + if (textAreaWidget.editor) + { + jQuery(textAreaWidget.editor.iframeElement.contentWindow.document).on('dragenter', function () + { + // anything to bind on tinymce iframe + }); + } }); } else @@ -389,7 +396,6 @@ app.classes.mail = AppJS.extend( e.stopImmediatePropagation(); return false; } - that.compose_resizeHandler(); }); // Init key handler this.init_keyHandler(); @@ -3936,9 +3942,6 @@ app.classes.mail = AppJS.extend( var groupbox = boxAttachment.getParent(); if (groupbox) groupbox.set_disabled(false); } - //Resize the compose dialog - var self = this; - setTimeout(function(){self.compose_resizeHandler();}, 100); return true; }, @@ -4672,65 +4675,7 @@ app.classes.mail = AppJS.extend( } }, - /** - * Control textArea size based on available free space at the bottom - * - */ - compose_resizeHandler: function() - { - // Do not resize compose dialog if it's running on mobile device - // in this case user would be able to edit mail body by scrolling down, - // which is more convenient on small devices. Also resize mailbody with - // tinyMCE may causes performance regression, especially on devices with - // very limited resources and slow proccessor. - if (egwIsMobile()) return false; - - try { - var bodyH = egw_getWindowInnerHeight(); - var textArea = this.et2.getWidgetById('mail_plaintext'); - var $headerSec = jQuery('.mailComposeHeaderSection'); - var content = this.et2.getArrayMgr('content').data; - - if (typeof textArea != 'undefined' && textArea != null) - { - if (textArea.getParent().disabled) - { - textArea = this.et2.getWidgetById('mail_htmltext'); - } - // Tolerate values base on plain text or html, in order to calculate freespaces - var textAreaDelta = textArea.id == "mail_htmltext"?20:40; - - // while attachments are in progress take progress visiblity into account - // otherwise the attachment progress is finished and consider attachments list - var delta = textAreaDelta; - - var bodySize = (bodyH - Math.round($headerSec.height() + $headerSec.offset().top) - delta); - - if (textArea.id != "mail_htmltext") - { - textArea.getParent().style.height = `${bodySize}px`; - } - else if (typeof textArea != 'undefined' && textArea.id == 'mail_htmltext') - { - if (textArea.editor) - { - jQuery(textArea.editor.editorContainer).height(bodySize); - jQuery(textArea.editor.iframeElement).height(bodySize - (textArea.editor.editorContainer.getElementsByClassName('tox-toolbar')[0].clientHeight + - textArea.editor.editorContainer.getElementsByClassName('tox-statusbar')[0].clientHeight)); - } - } - else - { - textArea.set_height(bodySize - 90); - } - } - } - catch(e) { - // ignore errors causing compose to load twice - } - }, - - /** + /** * Display Folder,Cc or Bcc fields in compose popup * * @param {jQuery event} event @@ -4823,7 +4768,6 @@ app.classes.mail = AppJS.extend( } } } - this.compose_resizeHandler(); }, /** diff --git a/mail/templates/default/compose.xet b/mail/templates/default/compose.xet index 576a70eb02..9579786c11 100644 --- a/mail/templates/default/compose.xet +++ b/mail/templates/default/compose.xet @@ -1,7 +1,7 @@ - \ No newline at end of file