forked from extern/egroupware
* Mail: Add custom html toolbar settings in mail site-configuration in order to be able to add/remove certain actions only for mail-compose dialog.
This commit is contained in:
parent
b88a8771b9
commit
bf3c833856
@ -268,9 +268,12 @@ var et2_htmlarea = /** @class */ (function (_super) {
|
|||||||
var rte_menubar = egw.preference('rte_menubar', 'common');
|
var rte_menubar = egw.preference('rte_menubar', 'common');
|
||||||
var rte_toolbar = egw.preference('rte_toolbar', 'common');
|
var rte_toolbar = egw.preference('rte_toolbar', 'common');
|
||||||
// we need to have rte_toolbar values as an array
|
// we need to have rte_toolbar values as an array
|
||||||
if (rte_toolbar && typeof rte_toolbar == "object") {
|
if (rte_toolbar && typeof rte_toolbar == "object" && this.toolbar == '') {
|
||||||
rte_toolbar = Object.keys(rte_toolbar).map(function (key) { return rte_toolbar[key]; });
|
rte_toolbar = Object.keys(rte_toolbar).map(function (key) { return rte_toolbar[key]; });
|
||||||
}
|
}
|
||||||
|
else if (this.toolbar != '') {
|
||||||
|
rte_toolbar = this.toolbar.split(',');
|
||||||
|
}
|
||||||
var settings = {
|
var settings = {
|
||||||
fontsize_formats: et2_htmlarea.FONT_SIZE_FORMATS[egw.preference('rte_font_unit', 'common')],
|
fontsize_formats: et2_htmlarea.FONT_SIZE_FORMATS[egw.preference('rte_font_unit', 'common')],
|
||||||
menubar: parseInt(rte_menubar) && this.menubar ? true : typeof rte_menubar != 'undefined' ? false : this.menubar
|
menubar: parseInt(rte_menubar) && this.menubar ? true : typeof rte_menubar != 'undefined' ? false : this.menubar
|
||||||
@ -417,6 +420,12 @@ var et2_htmlarea = /** @class */ (function (_super) {
|
|||||||
description: "Enables to control what child tag is allowed or not allowed of the present tag. For instance: +body[style], makes style tag allowed inside body",
|
description: "Enables to control what child tag is allowed or not allowed of the present tag. For instance: +body[style], makes style tag allowed inside body",
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "+body[style]"
|
default: "+body[style]"
|
||||||
|
},
|
||||||
|
toolbar: {
|
||||||
|
'name': 'Toolbar',
|
||||||
|
'description': 'Comma separated string of toolbar actions. It will only be considered if no Mode is restricted.',
|
||||||
|
'default': '',
|
||||||
|
'type': 'string'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -426,7 +435,7 @@ var et2_htmlarea = /** @class */ (function (_super) {
|
|||||||
et2_htmlarea.TOOLBAR_LIST = ['undo', 'redo', 'formatselect', 'fontselect', 'fontsizeselect',
|
et2_htmlarea.TOOLBAR_LIST = ['undo', 'redo', 'formatselect', 'fontselect', 'fontsizeselect',
|
||||||
'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor', 'link',
|
'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor', 'link',
|
||||||
'alignleft', 'aligncenter', 'alignright', 'alignjustify', 'numlist',
|
'alignleft', 'aligncenter', 'alignright', 'alignjustify', 'numlist',
|
||||||
'bullist', 'outdent', 'indent', 'ltr', 'rtl', 'removeformat', 'code', 'image', 'searchreplace'
|
'bullist', 'outdent', 'indent', 'ltr', 'rtl', 'removeformat', 'code', 'image', 'searchreplace', 'fullscreen'
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* arranged toolbars as simple mode
|
* arranged toolbars as simple mode
|
||||||
@ -447,8 +456,8 @@ var et2_htmlarea = /** @class */ (function (_super) {
|
|||||||
* @constant
|
* @constant
|
||||||
*/
|
*/
|
||||||
et2_htmlarea.TOOLBAR_ADVANCED = "undo redo| formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | " +
|
et2_htmlarea.TOOLBAR_ADVANCED = "undo redo| formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | " +
|
||||||
"link | alignleft aligncenter alignright alignjustify | numlist " +
|
"alignleft aligncenter alignright alignjustify | numlist " +
|
||||||
"bullist outdent indent ltr rtl | removeformat code| image | searchreplace | fullscreen";
|
"bullist outdent indent ltr rtl | removeformat code| link image pastetext | searchreplace | fullscreen";
|
||||||
/**
|
/**
|
||||||
* font size formats
|
* font size formats
|
||||||
* @constant
|
* @constant
|
||||||
|
@ -83,6 +83,12 @@ class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
|
|||||||
description: "Enables to control what child tag is allowed or not allowed of the present tag. For instance: +body[style], makes style tag allowed inside body",
|
description: "Enables to control what child tag is allowed or not allowed of the present tag. For instance: +body[style], makes style tag allowed inside body",
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "+body[style]"
|
default: "+body[style]"
|
||||||
|
},
|
||||||
|
toolbar: {
|
||||||
|
'name': 'Toolbar',
|
||||||
|
'description': 'Comma separated string of toolbar actions. It will only be considered if no Mode is restricted.',
|
||||||
|
'default': '',
|
||||||
|
'type': 'string'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,7 +99,7 @@ class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
|
|||||||
public static readonly TOOLBAR_LIST : string[] = ['undo', 'redo', 'formatselect', 'fontselect', 'fontsizeselect',
|
public static readonly TOOLBAR_LIST : string[] = ['undo', 'redo', 'formatselect', 'fontselect', 'fontsizeselect',
|
||||||
'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor', 'link',
|
'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor', 'link',
|
||||||
'alignleft', 'aligncenter', 'alignright', 'alignjustify', 'numlist',
|
'alignleft', 'aligncenter', 'alignright', 'alignjustify', 'numlist',
|
||||||
'bullist', 'outdent', 'indent', 'ltr', 'rtl', 'removeformat', 'code', 'image', 'searchreplace'
|
'bullist', 'outdent', 'indent', 'ltr', 'rtl', 'removeformat', 'code', 'image', 'searchreplace', 'fullscreen'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,8 +123,8 @@ class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
|
|||||||
* @constant
|
* @constant
|
||||||
*/
|
*/
|
||||||
public static readonly TOOLBAR_ADVANCED : string = "undo redo| formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+
|
public static readonly TOOLBAR_ADVANCED : string = "undo redo| formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+
|
||||||
"link | alignleft aligncenter alignright alignjustify | numlist "+
|
"alignleft aligncenter alignright alignjustify | numlist "+
|
||||||
"bullist outdent indent ltr rtl | removeformat code| image | searchreplace | fullscreen";
|
"bullist outdent indent ltr rtl | removeformat code| link image pastetext | searchreplace | fullscreen";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* font size formats
|
* font size formats
|
||||||
@ -146,6 +152,7 @@ class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
|
|||||||
supportedWidgetClasses : any;
|
supportedWidgetClasses : any;
|
||||||
htmlNode : JQuery = null;
|
htmlNode : JQuery = null;
|
||||||
mode : string;
|
mode : string;
|
||||||
|
toolbar: string;
|
||||||
tinymce : any;
|
tinymce : any;
|
||||||
tinymce_container : HTMLElement;
|
tinymce_container : HTMLElement;
|
||||||
file_picker_callback : Function;
|
file_picker_callback : Function;
|
||||||
@ -409,10 +416,14 @@ class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
|
|||||||
let rte_menubar = <string>egw.preference('rte_menubar', 'common');
|
let rte_menubar = <string>egw.preference('rte_menubar', 'common');
|
||||||
let rte_toolbar = egw.preference('rte_toolbar', 'common');
|
let rte_toolbar = egw.preference('rte_toolbar', 'common');
|
||||||
// we need to have rte_toolbar values as an array
|
// we need to have rte_toolbar values as an array
|
||||||
if (rte_toolbar && typeof rte_toolbar == "object")
|
if (rte_toolbar && typeof rte_toolbar == "object" && this.toolbar == '')
|
||||||
{
|
{
|
||||||
rte_toolbar = Object.keys(rte_toolbar).map(function(key){return rte_toolbar[key]});
|
rte_toolbar = Object.keys(rte_toolbar).map(function(key){return rte_toolbar[key]});
|
||||||
}
|
}
|
||||||
|
else if(this.toolbar != '')
|
||||||
|
{
|
||||||
|
rte_toolbar = this.toolbar.split(',');
|
||||||
|
}
|
||||||
let settings = {
|
let settings = {
|
||||||
fontsize_formats: et2_htmlarea.FONT_SIZE_FORMATS[<string>egw.preference('rte_font_unit', 'common')],
|
fontsize_formats: et2_htmlarea.FONT_SIZE_FORMATS[<string>egw.preference('rte_font_unit', 'common')],
|
||||||
menubar: parseInt(rte_menubar) && this.menubar ? true : typeof rte_menubar != 'undefined' ? false : this.menubar
|
menubar: parseInt(rte_menubar) && this.menubar ? true : typeof rte_menubar != 'undefined' ? false : this.menubar
|
||||||
|
@ -26,15 +26,24 @@ class HtmlArea extends Etemplate\Widget
|
|||||||
* @var type array
|
* @var type array
|
||||||
*/
|
*/
|
||||||
public static $font_options = array(
|
public static $font_options = array(
|
||||||
|
'andale mono,times' => 'Andale Mono',
|
||||||
'arial, helvetica, sans-serif' => 'Arial',
|
'arial, helvetica, sans-serif' => 'Arial',
|
||||||
|
'arial black,avant garde' => 'Arial Black',
|
||||||
|
'book antiqua,palatino' => 'Book Antiqua',
|
||||||
'Comic Sans MS, cursive' => 'Comic Sans MS',
|
'Comic Sans MS, cursive' => 'Comic Sans MS',
|
||||||
'Courier New, Courier, monospace' => 'Courier New',
|
'Courier New, Courier, monospace' => 'Courier New',
|
||||||
'Georgia, serif' => 'Georgia',
|
'Georgia, serif' => 'Georgia',
|
||||||
|
'helvetica' => 'Helvetica',
|
||||||
|
'impact,chicago' => 'Impact',
|
||||||
'Lucida Sans Unicode, Lucida Grande, sans-serif' => 'Lucida Sans Unicode',
|
'Lucida Sans Unicode, Lucida Grande, sans-serif' => 'Lucida Sans Unicode',
|
||||||
|
'symbol' => 'Symbol',
|
||||||
'Tahoma, Geneva, sans-serif' => 'Tahoma',
|
'Tahoma, Geneva, sans-serif' => 'Tahoma',
|
||||||
|
'terminal, "monaco' => 'Terminal',
|
||||||
'times new roman, times, serif' => 'Times New Roman',
|
'times new roman, times, serif' => 'Times New Roman',
|
||||||
'Trebuchet MS, Helvetica, sans-serif' => 'Trebuchet MS',
|
'Trebuchet MS, Helvetica, sans-serif' => 'Trebuchet MS',
|
||||||
'Verdana, Geneva, sans-serif' => 'Verdana'
|
'Verdana, Geneva, sans-serif' => 'Verdana',
|
||||||
|
'webdings' => 'Webdings',
|
||||||
|
'wingdings,zapf dingbats' => 'Wingdings'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,6 +78,56 @@ class HtmlArea extends Etemplate\Widget
|
|||||||
'px' => 'px: display pixels',
|
'px' => 'px: display pixels',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of exisitng toolbar actions
|
||||||
|
* @var type array
|
||||||
|
*/
|
||||||
|
public static $toolbar_list = [
|
||||||
|
'undo', 'redo', 'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor',
|
||||||
|
'link', 'alignleft', 'aligncenter', 'alignright', 'alignjustify',
|
||||||
|
'numlist', 'bullist', 'outdent', 'indent', 'ltr', 'rtl','pastetext',
|
||||||
|
'removeformat', 'code', 'image', 'searchreplace','formatselect', 'fontselect', 'fontsizeselect', 'fullscreen'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default list of toolbar actions
|
||||||
|
* @var type array
|
||||||
|
*/
|
||||||
|
public static $toolbar_default_list = [
|
||||||
|
'undo', 'redo','formatselect', 'fontselect', 'fontsizeselect',
|
||||||
|
'bold' ,'italic', 'removeformat', 'forecolor', 'backcolor', 'alignleft',
|
||||||
|
'aligncenter', 'alignright', 'alignjustify', 'numlist', 'bullist', 'outdent',
|
||||||
|
'indent', 'link', 'image', 'pastetext'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an array of toolbar as sel options
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* [
|
||||||
|
* id => {string}
|
||||||
|
* label => {string}
|
||||||
|
* title => {string}
|
||||||
|
* icon => {string}
|
||||||
|
* app => {string}
|
||||||
|
* ]
|
||||||
|
*/
|
||||||
|
public static function get_toolbar_as_selOptions ()
|
||||||
|
{
|
||||||
|
$toolbar_selOptions = array();
|
||||||
|
foreach (self::$toolbar_list as $toolbar)
|
||||||
|
{
|
||||||
|
$toolbar_selOptions[$toolbar] = array (
|
||||||
|
'id' => $toolbar,
|
||||||
|
'label' => lang($toolbar),
|
||||||
|
'title' => lang($toolbar),
|
||||||
|
'icon' => Api\Framework::getUrl($GLOBALS['egw_info']['server']['webserver_url']).'/api/templates/default/images/htmlarea/'.$toolbar.'.svg',
|
||||||
|
'app' => 'api'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $toolbar_selOptions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate input
|
* Validate input
|
||||||
*
|
*
|
||||||
|
@ -1394,6 +1394,8 @@ class mail_compose
|
|||||||
}
|
}
|
||||||
|
|
||||||
$content['to'] = self::resolveEmailAddressList($content['to']);
|
$content['to'] = self::resolveEmailAddressList($content['to']);
|
||||||
|
$content['html_toolbar'] = empty(Mail::$mailConfig['html_toolbar']) ?
|
||||||
|
join(',', Etemplate\Widget\HtmlArea::$toolbar_default_list) : join(',', Mail::$mailConfig['html_toolbar']);
|
||||||
//error_log(__METHOD__.__LINE__.array2string($content));
|
//error_log(__METHOD__.__LINE__.array2string($content));
|
||||||
$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);
|
$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);
|
||||||
}
|
}
|
||||||
|
@ -732,4 +732,20 @@ class mail_hooks
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before displaying site configuration
|
||||||
|
*
|
||||||
|
* @param array $config
|
||||||
|
* @return array with additional config to merge and "sel_options" values
|
||||||
|
*/
|
||||||
|
public static function config(array $config)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'html_toolbar' => empty($config['html_toolbar']) ? join(',', Api\Etemplate\Widget\HtmlArea::$toolbar_default_list) : $config['html_toolbar'],
|
||||||
|
'sel_options' => [
|
||||||
|
'html_toolbar' => Api\Etemplate\Widget\HtmlArea::get_toolbar_as_selOptions()
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ $setup_info['mail']['hooks']['clear_cache'] = 'EGroupware\\Api\\Mail::unsetCache
|
|||||||
$setup_info['mail']['hooks']['check_notify'] = 'mail_hooks::notification_check_mailbox';
|
$setup_info['mail']['hooks']['check_notify'] = 'mail_hooks::notification_check_mailbox';
|
||||||
$setup_info['mail']['hooks']['emailadmin_edit'] = 'mail_hooks::emailadmin_edit';
|
$setup_info['mail']['hooks']['emailadmin_edit'] = 'mail_hooks::emailadmin_edit';
|
||||||
$setup_info['mail']['hooks']['status-get_actions'] = 'mail_hooks::get_status_actions';
|
$setup_info['mail']['hooks']['status-get_actions'] = 'mail_hooks::get_status_actions';
|
||||||
|
$setup_info['mail']['hooks']['config'] = 'mail_hooks::config';
|
||||||
|
|
||||||
/* Dependencies for this app to work */
|
/* Dependencies for this app to work */
|
||||||
$setup_info['mail']['depends'][] = array(
|
$setup_info['mail']['depends'][] = array(
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
</vbox>
|
</vbox>
|
||||||
<vbox class="mailComposeBodySection" width="100%">
|
<vbox class="mailComposeBodySection" width="100%">
|
||||||
<hbox disabled="@is_plain" class="mailComposeBody mailComposeHtmlContainer">
|
<hbox disabled="@is_plain" class="mailComposeBody mailComposeHtmlContainer">
|
||||||
<htmlarea name="mail_htmltext" id="mail_htmltext" statusbar="false" menubar="false" mode="simple" imageUpload="link_to" expand_toolbar="true" height="478px" width="100%" resize_ratio="0"/>
|
<htmlarea name="mail_htmltext" id="mail_htmltext" statusbar="false" menubar="false" toolbar="@html_toolbar" imageUpload="link_to" expand_toolbar="true" height="478px" width="100%" resize_ratio="0"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<hbox disabled="@is_html" class="mailComposeBody mailComposeTextContainer">
|
<hbox disabled="@is_html" class="mailComposeBody mailComposeTextContainer">
|
||||||
<textbox multiline="true" rows="40" cols="120" width="100%" span="all" no_lang="1" name="mail_plaintext" id="mail_plaintext" resize_ratio="0"/>
|
<textbox multiline="true" rows="40" cols="120" width="100%" span="all" no_lang="1" name="mail_plaintext" id="mail_plaintext" resize_ratio="0"/>
|
||||||
|
@ -81,6 +81,10 @@
|
|||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<description value="Miscellaneous" span="all" class="subHeader"/>
|
<description value="Miscellaneous" span="all" class="subHeader"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<description value="Default toolbar actions shown in mail's HTML editor"/>
|
||||||
|
<taglist id="newsettings[html_toolbar]" allowFreeEntries="false" autocomplete_url=' ' editModeEnabled="false"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<vbox>
|
<vbox>
|
||||||
|
@ -113,23 +113,6 @@ class preferences_hooks
|
|||||||
$GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'],
|
$GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'],
|
||||||
$GLOBALS['egw_info']['user']['preferences']['common']['rte_font_unit']);
|
$GLOBALS['egw_info']['user']['preferences']['common']['rte_font_unit']);
|
||||||
}
|
}
|
||||||
$rte_toolbar_list = array (
|
|
||||||
'undo', 'redo', 'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor',
|
|
||||||
'link', 'alignleft', 'aligncenter', 'alignright', 'alignjustify',
|
|
||||||
'numlist', 'bullist', 'outdent', 'indent', 'ltr', 'rtl',
|
|
||||||
'removeformat', 'code', 'image', 'searchreplace','formatselect', 'fontselect', 'fontsizeselect', 'fullscreen'
|
|
||||||
);
|
|
||||||
$rte_toolbar_selOptions = array();
|
|
||||||
foreach ($rte_toolbar_list as $toolbar)
|
|
||||||
{
|
|
||||||
$rte_toolbar_selOptions[$toolbar] = array (
|
|
||||||
'id' => $toolbar,
|
|
||||||
'label' => lang($toolbar),
|
|
||||||
'title' => lang($toolbar),
|
|
||||||
'icon' => Framework::getUrl($GLOBALS['egw_info']['server']['webserver_url']).'/api/templates/default/images/htmlarea/'.$toolbar.'.svg',
|
|
||||||
'app' => 'api'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$GLOBALS['egw_info']['user']['preferences']['common']['rte_toolbar'])
|
if (!$GLOBALS['egw_info']['user']['preferences']['common']['rte_toolbar'])
|
||||||
{
|
{
|
||||||
@ -475,7 +458,7 @@ class preferences_hooks
|
|||||||
//'multiple' => 'toggle',
|
//'multiple' => 'toggle',
|
||||||
'editModeEnabled' => false,
|
'editModeEnabled' => false,
|
||||||
'autocomplete_url' => ' ',
|
'autocomplete_url' => ' ',
|
||||||
'select_options' => $rte_toolbar_selOptions
|
'select_options' => Api\Etemplate\Widget\HtmlArea::get_toolbar_as_selOptions()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user