Replace my old ResizeObserver workaround for RainLoop bugs with proper CSS flex.

And removed wysiwyg resize() in favor of flexbox.
This commit is contained in:
djmaze 2021-11-05 14:47:19 +01:00
parent d305e090c5
commit 789dc264f7
11 changed files with 386 additions and 441 deletions

View file

@ -29,12 +29,6 @@ export class HtmlEditor {
this.onBlur = onBlur; this.onBlur = onBlur;
this.onModeChange = onModeChange; this.onModeChange = onModeChange;
this.resize = (() => {
try {
this.editor && this.editor.resize(element.clientWidth, element.clientHeight);
} catch (e) {} // eslint-disable-line no-empty
}).throttle(100);
if (element) { if (element) {
let editor; let editor;
@ -42,7 +36,6 @@ export class HtmlEditor {
this.onReady = fn => onReady.push(fn); this.onReady = fn => onReady.push(fn);
const readyCallback = () => { const readyCallback = () => {
this.editor = editor; this.editor = editor;
this.resize();
this.onReady = fn => fn(); this.onReady = fn => fn();
onReady.forEach(fn => fn()); onReady.forEach(fn => fn());
}; };

View file

@ -540,12 +540,6 @@ class SquireUI
focus() { focus() {
('plain' == this.mode ? this.plain : this.squire).focus(); ('plain' == this.mode ? this.plain : this.squire).focus();
} }
resize(width, height) {
height = Math.max(200, (height - this.wysiwyg.offsetTop)) + 'px';
this.wysiwyg.style.height = height;
this.plain.style.height = height;
}
} }
this.SquireUI = SquireUI; this.SquireUI = SquireUI;

View file

@ -2,21 +2,32 @@
.b-compose { .b-compose {
&.modal { &.modal {
width: 98%; display: flex;
flex-direction: column;
height: calc(100% - 52px);
max-width: 1000px; max-width: 1000px;
min-height: calc(100% - 52px); width: 98%;
} }
.modal-body { .modal-body {
padding: 0; padding: 0;
display: flex;
flex-direction: column;
height: 100%;
} }
.textAreaParent, .attachmentAreaParent { .textAreaParent, .attachmentAreaParent {
box-sizing: border-box; box-sizing: border-box;
height: 100%;
min-height: 200px; min-height: 200px;
position: relative; position: relative;
} }
.textAreaParent {
display: flex;
flex-direction: column;
}
.attachmentAreaParent { .attachmentAreaParent {
border-top: 1px solid #ccc; border-top: 1px solid #ccc;
overflow-y: auto; overflow-y: auto;

View file

@ -13,6 +13,11 @@ html.rl-no-preview-pane {
.messageList { .messageList {
height: 100%; height: 100%;
background-color: #fff;
border: 1px solid @rlMainDarkColor;
border-radius: @rlMainBorderRadius;
box-shadow: @rlMainShadow;
z-index: 101;
.toolbar { .toolbar {
position: absolute; position: absolute;
@ -25,14 +30,15 @@ html.rl-no-preview-pane {
white-space: nowrap; white-space: nowrap;
} }
.b-message-list-wrapper {
display: flex;
flex-direction: column;
height: 100%;
}
.b-footer { .b-footer {
position: absolute; flex-shrink: 0;
bottom: 0;
right: 0;
left: 0;
height: 30px;
padding: 7px; padding: 7px;
z-index: 101;
background-color: var(--message-list-toolbar-bg-color, #eee); background-color: var(--message-list-toolbar-bg-color, #eee);
// #gradient > .vertical(#f4f4f4, #dfdfdf); // #gradient > .vertical(#f4f4f4, #dfdfdf);
@ -59,23 +65,9 @@ html.rl-no-preview-pane {
padding-right: 8px; padding-right: 8px;
} }
.b-message-list-wrapper {
border: 1px solid @rlMainDarkColor;
height: 100%;
box-shadow: @rlMainShadow;
border-radius: @rlMainBorderRadius;
z-index: 101;
}
.second-toolbar { .second-toolbar {
position: absolute; flex-shrink: 0;
top: 0;
right: 0;
left: 0;
height: 29px;
padding: 10px 8px 10px 11px; padding: 10px 8px 10px 11px;
z-index: 101;
white-space: nowrap; white-space: nowrap;
background-color: var(--message-list-toolbar-bg-color, #eee); background-color: var(--message-list-toolbar-bg-color, #eee);
@ -108,18 +100,11 @@ html.rl-no-preview-pane {
} }
.b-content { .b-content {
position: absolute; height: 100%;
top: 50px;
bottom: 45px;
left: 0;
right: 0;
padding: 0; padding: 0;
overflow: auto; overflow: auto;
z-index: 101;
scroll-behavior: smooth; scroll-behavior: smooth;
background-color: #fff;
.listClear { .listClear {
text-align: center; text-align: center;
padding: 10px; padding: 10px;
@ -179,8 +164,7 @@ html.rl-no-preview-pane {
} }
} }
&.focused .b-message-list-wrapper { &.focused {
background-color: #000;
border-color: #9d9d9d; border-color: #9d9d9d;
} }
} }

View file

@ -3,6 +3,9 @@
} }
.messageView { .messageView {
background-color: #fff;
border: 1px solid @rlMainDarkColor;
border-radius: @rlMainBorderRadius;
height: 100%; height: 100%;
.toolbar { .toolbar {
@ -16,10 +19,14 @@
} }
.b-content { .b-content {
background-color: #fff;
border: 1px solid @rlMainDarkColor;
border-radius: @rlMainBorderRadius;
height: 100%; height: 100%;
}
.b-message {
display: flex;
flex-direction: column;
height: 100%;
}
.b-message-view-checked-helper { .b-message-view-checked-helper {
text-align: center; text-align: center;
@ -77,14 +84,14 @@
opacity: 0.5; opacity: 0.5;
} }
} }
}
.messageItemHeader { .messageItemHeader {
padding: 10px;
background-color: #f8f8f8; background-color: #f8f8f8;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
border-radius: @rlMainBorderRadius @rlMainBorderRadius 0 0; border-radius: @rlMainBorderRadius @rlMainBorderRadius 0 0;
padding: 10px;
flex-shrink: 0;
.subjectParent { .subjectParent {
font-size: 18px; font-size: 18px;
@ -162,11 +169,7 @@
.messageItem { .messageItem {
color: #000; color: #000;
position: absolute; height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: auto; overflow: auto;
scroll-behavior: smooth; scroll-behavior: smooth;
@ -443,8 +446,7 @@
} }
} }
&.focused .b-content { &.focused {
z-index: 101;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
border-color: darken(@rlMainDarkColor, 5%); border-color: darken(@rlMainDarkColor, 5%);
} }

View file

@ -1,9 +1,10 @@
.squire-toolbar { .squire-toolbar {
padding: 2px;
border-bottom: 1px solid #b6b6b6; border-bottom: 1px solid #b6b6b6;
min-height: 28px;
overflow-x: auto; overflow-x: auto;
overflow-y: hidden; overflow-y: hidden;
padding: 2px;
white-space: nowrap; white-space: nowrap;
} }
@ -38,6 +39,7 @@
.squire-wysiwyg, .squire-plain { .squire-wysiwyg, .squire-plain {
box-sizing: border-box; box-sizing: border-box;
font-size: 13px; font-size: 13px;
height: 100%;
line-height: 16px; line-height: 16px;
min-height: 200px; min-height: 200px;
overflow: auto; overflow: auto;
@ -155,16 +157,22 @@ Secondly, we can't rely on MUA's what to do with :empty
} }
/* @media (hover: none) */ /* @media (hover: none) */
.rl-mobile .textAreaParent:not(:focus-within) .squire-toolbar { @media screen and (max-height: 600px) {
.rl-mobile .textAreaParent:not(:focus-within) .squire-toolbar {
display: none; display: none;
} }
.rl-mobile .squire-toolbar { .rl-mobile .squire-toolbar {
background: #EEE; background: #EEE;
padding: 1px; padding: 1px;
position: fixed; position: fixed;
bottom: 0; top: 18px;
left: 0; left: 0;
right: 0; right: 0;
/*
transform: translateY(-42px);
z-index: 9;
*/
}
} }
.rl-mobile .b-compose.modal, .rl-mobile .b-compose.modal,

View file

@ -312,8 +312,6 @@ class ComposePopupView extends AbstractViewPopup {
} }
}); });
this.resizeObserver = new ResizeObserver(this.resizerTrigger.throttle(50).bind(this));
decorateKoCommands(this, { decorateKoCommands(this, {
sendCommand: self => self.canBeSentOrSaved(), sendCommand: self => self.canBeSentOrSaved(),
saveCommand: self => self.canBeSentOrSaved(), saveCommand: self => self.canBeSentOrSaved(),
@ -641,8 +639,6 @@ class ComposePopupView extends AbstractViewPopup {
rl.route.on(); rl.route.on();
this.resizeObserver.disconnect();
(getFullscreenElement() === this.oContent) && exitFullscreen(); (getFullscreenElement() === this.oContent) && exitFullscreen();
} }
@ -709,10 +705,6 @@ class ComposePopupView extends AbstractViewPopup {
onShow(type, oMessageOrArray, aToEmails, aCcEmails, aBccEmails, sCustomSubject, sCustomPlainText) { onShow(type, oMessageOrArray, aToEmails, aCcEmails, aBccEmails, sCustomSubject, sCustomPlainText) {
rl.route.off(); rl.route.off();
const ro = this.resizeObserver;
ro.observe(ro.compose);
ro.observe(ro.header);
this.autosaveStart(); this.autosaveStart();
this.viewModelDom.dataset.wysiwyg = SettingsUserStore.editorDefaultType(); this.viewModelDom.dataset.wysiwyg = SettingsUserStore.editorDefaultType();
@ -1088,7 +1080,7 @@ class ComposePopupView extends AbstractViewPopup {
} }
} }
onBuild(dom) { onBuild() {
// initUploader // initUploader
if (this.composeUploaderButton()) { if (this.composeUploaderButton()) {
@ -1249,12 +1241,6 @@ class ComposePopupView extends AbstractViewPopup {
return false; return false;
}); });
const ro = this.resizeObserver;
ro.compose = dom.querySelector('.b-compose');
ro.header = dom.querySelector('.b-header');
ro.toolbar = dom.querySelector('.b-header-toolbar');
ro.els = [dom.querySelector('.textAreaParent'), dom.querySelector('.attachmentAreaParent')];
this.editor(editor => editor[this.isPlainEditor()?'modePlain':'modeWysiwyg']()); this.editor(editor => editor[this.isPlainEditor()?'modePlain':'modeWysiwyg']());
// Fullscreen must be on app, else other popups fail // Fullscreen must be on app, else other popups fail
@ -1463,16 +1449,6 @@ class ComposePopupView extends AbstractViewPopup {
item => item.id item => item.id
); );
} }
resizerTrigger() {
let ro = this.resizeObserver,
height = Math.max(200, ro.compose.clientHeight - ro.header.offsetHeight - ro.toolbar.offsetHeight) + 'px';
if (ro.height !== height) {
ro.height = height;
ro.els.forEach(element => element.style.height = height);
this.oEditor && this.oEditor.resize();
}
}
} }
export { ComposePopupView, ComposePopupView as default }; export { ComposePopupView, ComposePopupView as default };

View file

@ -60,7 +60,6 @@ export class MailMessageView extends AbstractViewRight {
} }
}, this.messageVisibility); }, this.messageVisibility);
this.oHeaderDom = null;
this.oMessageScrollerDom = null; this.oMessageScrollerDom = null;
this.addObservables({ this.addObservables({
@ -116,7 +115,6 @@ export class MailMessageView extends AbstractViewRight {
this.viewUid = ''; this.viewUid = '';
this.viewHash = ''; this.viewHash = '';
this.addObservables({ this.addObservables({
viewBodyTopValue: 0,
viewSubject: '', viewSubject: '',
viewFromShort: '', viewFromShort: '',
viewFromDkimData: ['none', ''], viewFromDkimData: ['none', ''],
@ -304,10 +302,6 @@ export class MailMessageView extends AbstractViewRight {
showMessageComposer([sType, MessageUserStore.message()]); showMessageComposer([sType, MessageUserStore.message()]);
} }
checkHeaderHeight() {
this.oHeaderDom && this.viewBodyTopValue(MessageUserStore.message() ? this.oHeaderDom.offsetHeight : 0);
}
onBuild(dom) { onBuild(dom) {
this.oMessageScrollerDom = dom.querySelector('.messageItem'); this.oMessageScrollerDom = dom.querySelector('.messageItem');
@ -316,19 +310,8 @@ export class MailMessageView extends AbstractViewRight {
this.showFullInfo.subscribe(value => Local.set(ClientSideKeyName.MessageHeaderFullInfo, value ? '1' : '0')); this.showFullInfo.subscribe(value => Local.set(ClientSideKeyName.MessageHeaderFullInfo, value ? '1' : '0'));
let el = dom.querySelector('.messageItemHeader'); let event = 'fullscreenchange',
this.oHeaderDom = el; el = dom.querySelector('.b-content');
if (el) {
if (!this.resizeObserver) {
this.resizeObserver = new ResizeObserver(this.checkHeaderHeight.debounce(50).bind(this));
}
this.resizeObserver.observe(el);
} else if (this.resizeObserver) {
this.resizeObserver.disconnect();
}
let event = 'fullscreenchange';
el = dom.querySelector('.b-message-view-wrapper');
if (!el.requestFullscreen && el.webkitRequestFullscreen) { if (!el.requestFullscreen && el.webkitRequestFullscreen) {
el.requestFullscreen = el.webkitRequestFullscreen; el.requestFullscreen = el.webkitRequestFullscreen;
event = 'webkit'+event; event = 'webkit'+event;

View file

@ -23,8 +23,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="b-content b-message-view-wrapper"> <div class="b-content">
<div style="height: 100%">
<div class="b-message-view-backdrop" data-bind="visible: moveAction"> <div class="b-message-view-backdrop" data-bind="visible: moveAction">
<div class="backdrop-message"> <div class="backdrop-message">
<i class="fontastic">📁</i> <i class="fontastic">📁</i>
@ -158,7 +157,7 @@
</div> </div>
</div> </div>
<div data-bind="visible: message"> <div class="b-message" data-bind="visible: message">
<div class="messageItemHeader" data-bind="css: {'emptySubject': '' === viewSubject()}"> <div class="messageItemHeader" data-bind="css: {'emptySubject': '' === viewSubject()}">
<div class="subjectParent"> <div class="subjectParent">
<button class="close" data-bind="command: closeMessageCommand" style="margin-top: -2px;">×</button> <button class="close" data-bind="command: closeMessageCommand" style="margin-top: -2px;">×</button>
@ -241,7 +240,7 @@
</div> </div>
<div class="hasVirus" data-bind="visible: hasVirus()" data-i18n="MESSAGE/HAS_VIRUS_WARNING"></div> <div class="hasVirus" data-bind="visible: hasVirus()" data-i18n="MESSAGE/HAS_VIRUS_WARNING"></div>
</div> </div>
<div class="messageItem" data-bind="css: viewLineAsCss(), attr: {'style': 'top:' + viewBodyTopValue() + 'px' }"> <div class="messageItem" data-bind="css: viewLineAsCss()">
<div tabindex="0" data-bind="hasfocus: messageDomFocused"> <div tabindex="0" data-bind="hasfocus: messageDomFocused">
<div> <div>
@ -318,5 +317,4 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>

View file

@ -153,7 +153,7 @@
</table> </table>
</div> </div>
<div class="attachmentAreaParent b-content" data-bind="visible: attachmentsPlace"> <div class="attachmentAreaParent" data-bind="visible: attachmentsPlace">
<div class="b-attachment-place" data-bind="visible: addAttachmentEnabled() && dragAndDropVisible(), initDom: composeUploaderDropPlace, css: {'dragAndDropOver': dragAndDropOver}" <div class="b-attachment-place" data-bind="visible: addAttachmentEnabled() && dragAndDropVisible(), initDom: composeUploaderDropPlace, css: {'dragAndDropOver': dragAndDropOver}"
data-i18n="COMPOSE/ATTACH_DROP_FILES_DESC"></div> data-i18n="COMPOSE/ATTACH_DROP_FILES_DESC"></div>
<ul class="attachmentList" data-bind="foreach: attachments"> <ul class="attachmentList" data-bind="foreach: attachments">

View file

@ -71,15 +71,11 @@
border-top-color: var(--main-color); border-top-color: var(--main-color);
} }
.messageList .b-message-list-wrapper {
border-color: #555;
}
.well, .well,
.modal, .modal,
.b-settins-right .b-content, .b-settins-right .b-content,
.messageList .b-content, .messageList,
.messageView .b-content, .messageView,
.b-admin-right .b-content, .b-admin-right .b-content,
.b-compose .b-attachment-place { .b-compose .b-attachment-place {
background-color: #000; background-color: #000;