Bugfix and improve Squire HTML/Plain modes

This commit is contained in:
djmaze 2021-08-16 18:09:54 +02:00
parent 5efbcf5ad3
commit 1c95eab6d6
4 changed files with 17 additions and 13 deletions

View file

@ -30,7 +30,7 @@ export function pString(value) {
export function inFocus() { export function inFocus() {
try { try {
return doc.activeElement && doc.activeElement.matches( return doc.activeElement && doc.activeElement.matches(
'input,textarea,.cke_editable' 'input,textarea,[contenteditable]'
); );
} catch (e) { } catch (e) {
return false; return false;

View file

@ -336,7 +336,7 @@ class SquireUI
} }
plain.className = 'squire-plain'; plain.className = 'squire-plain';
wysiwyg.className = 'squire-wysiwyg cke_editable'; wysiwyg.className = 'squire-wysiwyg';
this.mode = ''; // 'plain' | 'wysiwyg' this.mode = ''; // 'plain' | 'wysiwyg'
this.__plain = { this.__plain = {
getRawData: () => this.plain.value, getRawData: () => this.plain.value,
@ -349,18 +349,17 @@ class SquireUI
this.wysiwyg = wysiwyg; this.wysiwyg = wysiwyg;
toolbar.className = 'squire-toolbar btn-toolbar'; toolbar.className = 'squire-toolbar btn-toolbar';
let touchTap; let group, action, touchTap;
for (let group in actions) { for (group in actions) {
/*
if ('bidi' == group && !rl.settings.app('allowHtmlEditorBitiButtons')) { if ('bidi' == group && !rl.settings.app('allowHtmlEditorBitiButtons')) {
continue; continue;
} }
*/
let toolgroup = doc.createElement('div'); let toolgroup = doc.createElement('div');
toolgroup.className = 'btn-group'; toolgroup.className = 'btn-group';
toolgroup.id = 'squire-toolgroup-'+group; toolgroup.id = 'squire-toolgroup-'+group;
for (let action in actions[group]) { for (action in actions[group]) {
if ('source' == action && !rl.settings.app('allowHtmlEditorSourceButton')) {
continue;
}
let cfg = actions[group][action], input, ev = 'click'; let cfg = actions[group][action], input, ev = 'click';
if (cfg.input) { if (cfg.input) {
input = doc.createElement('input'); input = doc.createElement('input');

View file

@ -175,3 +175,7 @@ Secondly, we can't rely on MUA's what to do with :empty
.rl-mobile .b-compose.modal { .rl-mobile .b-compose.modal {
min-height: calc(100% - 62px); min-height: calc(100% - 62px);
} }
.RL-PopupsCompose[data-wysiwyg*=Forced] #squire-toolgroup-mode {
display: none;
}

View file

@ -130,7 +130,6 @@ class ComposePopupView extends AbstractViewPopup {
this.allowContacts = AppUserStore.allowContacts(); this.allowContacts = AppUserStore.allowContacts();
this.bSkipNextHide = false; this.bSkipNextHide = false;
this.editorDefaultType = SettingsUserStore.editorDefaultType;
this.capaOpenPGP = PgpUserStore.capaOpenPGP; this.capaOpenPGP = PgpUserStore.capaOpenPGP;
@ -716,6 +715,8 @@ class ComposePopupView extends AbstractViewPopup {
this.autosaveStart(); this.autosaveStart();
this.viewModelDom.dataset.wysiwyg = SettingsUserStore.editorDefaultType();
if (AppUserStore.composeInEdit()) { if (AppUserStore.composeInEdit()) {
type = type || ComposeType.Empty; type = type || ComposeType.Empty;
if (ComposeType.Empty !== type) { if (ComposeType.Empty !== type) {
@ -772,7 +773,7 @@ class ComposePopupView extends AbstractViewPopup {
} }
isPlainEditor() { isPlainEditor() {
let type = this.editorDefaultType(); let type = SettingsUserStore.editorDefaultType();
return EditorDefaultType.Html !== type && EditorDefaultType.HtmlForced !== type; return EditorDefaultType.Html !== type && EditorDefaultType.HtmlForced !== type;
} }
@ -971,8 +972,8 @@ class ComposePopupView extends AbstractViewPopup {
editor.setHtml(sText); editor.setHtml(sText);
if ( if (
EditorDefaultType.PlainForced === this.editorDefaultType() || EditorDefaultType.PlainForced === SettingsUserStore.editorDefaultType() ||
(!message.isHtml() && EditorDefaultType.HtmlForced !== this.editorDefaultType()) (!message.isHtml() && EditorDefaultType.HtmlForced !== SettingsUserStore.editorDefaultType())
) { ) {
editor.modePlain(); editor.modePlain();
} }
@ -1256,7 +1257,7 @@ class ComposePopupView extends AbstractViewPopup {
ro.toolbar = dom.querySelector('.b-header-toolbar'); ro.toolbar = dom.querySelector('.b-header-toolbar');
ro.els = [dom.querySelector('.textAreaParent'), dom.querySelector('.attachmentAreaParent')]; ro.els = [dom.querySelector('.textAreaParent'), dom.querySelector('.attachmentAreaParent')];
this.editor(editor => editor.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
const el = doc.getElementById('rl-app'); const el = doc.getElementById('rl-app');