diff --git a/api/js/etemplate/et2_widget_htmlarea.ts b/api/js/etemplate/et2_widget_htmlarea.ts index fe163896b1..df458fa2c9 100644 --- a/api/js/etemplate/et2_widget_htmlarea.ts +++ b/api/js/etemplate/et2_widget_htmlarea.ts @@ -100,6 +100,12 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable 'type': 'string', 'default': 'floating', 'description': 'It allows to extend the toolbar to accommodate the overflowing toolbar buttons. {floating, sliding, scrolling, wrap}' + }, + applyDefaultFont: { + name: 'apply default font and size', + type: 'boolean', + default: false, + description: 'Add default font and size as style attribute to the markup. Also ensures all non-block elements are wrapped in p.' } }; @@ -516,7 +522,10 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable this.editor.setContent(_value); // need to defer a little, so TinyMCE does its modifications we want to counter - window.setTimeout(() => this.wrapTextNodes(), 1); + if (this.options.applyDefaultFont) + { + window.setTimeout(() => this.wrapTextNodes(), 10); + } } else { @@ -532,22 +541,16 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable this.value = _value; } - /** - * Overwrite isValid to first "fix" the TinyMCE content, see wrapTextNodes - * - * @param _values - */ - isValid(_messages) - { - this.wrapTextNodes(); - - return super.isValid(_messages); - } - getValue() { if (this.editor) { + // are we called by etemplate2.getValues() (has a closure result) + // not always setting it, as getValue() is called a lot, e.g. to test input is dirty + if (this.options.applyDefaultFont && typeof result !== 'undefined') + { + this.applyDefaultFont(); + } return this.editor.getContent(); } return this.options.readonly ? this.value : this.htmlNode.val(); diff --git a/mail/js/app.js b/mail/js/app.js index 799e4d6a9a..28f1de92d4 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -5466,9 +5466,6 @@ app.classes.mail = AppJS.extend( this.compose_submitAction(false); } - // apply default font and -size before submitting to server for sending - this.et2?.getWidgetById('mail_htmltext')?.applyDefaultFont(); - return false; }, diff --git a/mail/templates/default/compose.xet b/mail/templates/default/compose.xet index eb8dd3411d..c5a63b75b0 100644 --- a/mail/templates/default/compose.xet +++ b/mail/templates/default/compose.xet @@ -139,7 +139,8 @@ - + diff --git a/mail/templates/mobile/compose.xet b/mail/templates/mobile/compose.xet index ea0fc47508..15fbdbb7bc 100644 --- a/mail/templates/mobile/compose.xet +++ b/mail/templates/mobile/compose.xet @@ -84,7 +84,8 @@ - +