diff --git a/api/js/etemplate/et2_widget_ckeditor.js b/api/js/etemplate/et2_widget_ckeditor.js index eb623ae7af..7ffa4ed799 100644 --- a/api/js/etemplate/et2_widget_ckeditor.js +++ b/api/js/etemplate/et2_widget_ckeditor.js @@ -13,9 +13,6 @@ /*egw:uses jsapi.jsapi; // Needed for egw_seperateJavaScript /vendor/bower-asset/jquery/dist/jquery.js; - /vendor/egroupware/ckeditor/ckeditor.js; - /vendor/egroupware/ckeditor/ckeditor.config; - /vendor/egroupware/ckeditor/ckeditor.adapters/jquery; et2_core_baseWidget; */ diff --git a/api/js/etemplate/et2_widget_htmlarea.js b/api/js/etemplate/et2_widget_htmlarea.js index 32a5f56d61..0355bbe5ae 100644 --- a/api/js/etemplate/et2_widget_htmlarea.js +++ b/api/js/etemplate/et2_widget_htmlarea.js @@ -21,10 +21,6 @@ */ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2_IResizeable], { - font_size_formats: { - pt: "8pt 10pt 12pt 14pt 18pt 24pt 36pt 48pt 72pt", - px:"8px 10px 12px 14px 18px 24px 36px 48px 72px" - }, attributes: { 'mode': { 'name': 'Mode', @@ -219,14 +215,16 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2 }, /** + * Takes all relevant preferences into account and set settings accordingly * - * @returns {et2_widget_htmlareaet2_htmlarea.et2_widget_htmlareaAnonym$1._extendedSettings.settings} + * @returns {object} returns a object including all settings */ _extendedSettings: function () { var rte_menubar = egw.preference('rte_menubar', 'common'); + var rte_toolbar = egw.preference('rte_toolbar', 'common'); var settings = { - fontsize_formats: this.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 }; @@ -234,21 +232,26 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2 switch (mode) { case 'simple': - settings.toolbar = "fontselect fontsizeselect | bold italic forecolor backcolor | "+ - "alignleft aligncenter alignright alignjustify | numlist "+ - "bullist outdent indent | link image" + settings.toolbar = et2_htmlarea.TOOLBAR_SIMPLE; break; case 'extended': - settings.toolbar = "fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+ - "link | alignleft aligncenter alignright alignjustify | numlist "+ - "bullist outdent indent | removeformat | image" + settings.toolbar = et2_htmlarera.TOOLBAR_EXTENDED; break; case 'advanced': - settings.toolbar = "undo redo| formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+ - "link | alignleft aligncenter alignright alignjustify | numlist "+ - "bullist outdent indent ltr rtl | removeformat code| image | searchreplace" + settings.toolbar = et2_htmlarea.TOOLBAR_ADVANCED; break; } + + // take rte_toolbar into account if no mode restrictly set from template + if (rte_toolbar && !this.mode) + { + var toolbar_diff = et2_htmlarea.TOOLBAR_LIST.filter((i) => {return !(rte_toolbar.indexOf(i) > -1);}); + settings.toolbar = et2_htmlarea.TOOLBAR_ADVANCED; + toolbar_diff.forEach((a) => { + let r = new RegExp(a); + settings.toolbar = settings.toolbar.replace(r, ''); + }); + } return settings; }, @@ -316,4 +319,46 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2 } } });}).call(this); -et2_register_widget(et2_htmlarea, ["htmlarea"]); \ No newline at end of file +et2_register_widget(et2_htmlarea, ["htmlarea"]); + +// Static class stuff +jQuery.extend(et2_htmlarea, { + /** + * Array of toolbars + * @constant + */ + TOOLBAR_LIST: ['undo', 'redo', 'formatselect', 'fontselect', 'fontsizeselect', + 'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor', 'link', + 'alignleft', 'aligncenter', 'alignright', 'alignjustify', 'numlist', + 'bullist', 'outdent', 'indent', 'ltr', 'rtl', 'removeformat', 'code', 'image', 'searchreplace' + ], + /** + * arranged toolbars as simple mode + * @constant + */ + TOOLBAR_SIMPLE: "fontselect fontsizeselect | bold italic forecolor backcolor | "+ + "alignleft aligncenter alignright alignjustify | numlist "+ + "bullist outdent indent | link image", + /** + * arranged toolbars as extended mode + * @constant + */ + TOOLBAR_EXTENDED: "fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+ + "link | alignleft aligncenter alignright alignjustify | numlist "+ + "bullist outdent indent | removeformat | image", + /** + * arranged toolbars as advanced mode + * @constant + */ + TOOLBAR_ADVANCED: "undo redo| formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+ + "link | alignleft aligncenter alignright alignjustify | numlist "+ + "bullist outdent indent ltr rtl | removeformat code| image | searchreplace", + /** + * font size formats + * @constant + */ + FONT_SIZE_FORMATS: { + pt: "8pt 10pt 12pt 14pt 18pt 24pt 36pt 48pt 72pt", + px:"8px 10px 12px 14px 18px 24px 36px 48px 72px" + } +}); \ No newline at end of file diff --git a/api/src/Etemplate/Widget/CkEditor.php b/api/src/Etemplate/Widget/CkEditor.php index 6a81b1b8b1..bda77cb0d2 100644 --- a/api/src/Etemplate/Widget/CkEditor.php +++ b/api/src/Etemplate/Widget/CkEditor.php @@ -37,6 +37,10 @@ class CkEditor extends Etemplate\Widget { $form_name = self::form_name($cname, $this->id); + Api\Framework::includeJS('/vendor/egroupware/ckeditor/ckeditor.js'); + Api\Framework::includeJS('/vendor/egroupware/ckeditor/ckeditor.config.js'); + Api\Framework::includeJS('/vendor/egroupware/ckeditor/ckeditor.adapters/jquery.js'); + $config = Api\Html\CkEditorConfig::get_ckeditor_config_array($this->attrs['mode'], $this->attrs['height'], $this->attrs['expand_toolbar'],$this->attrs['base_href'] ); diff --git a/api/templates/default/images/htmlarea/aligncenter.png b/api/templates/default/images/htmlarea/aligncenter.png new file mode 100644 index 0000000000..2da2dd4850 Binary files /dev/null and b/api/templates/default/images/htmlarea/aligncenter.png differ diff --git a/api/templates/default/images/htmlarea/aligncenter.svg b/api/templates/default/images/htmlarea/aligncenter.svg new file mode 100644 index 0000000000..075492cea4 --- /dev/null +++ b/api/templates/default/images/htmlarea/aligncenter.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/alignjustify.png b/api/templates/default/images/htmlarea/alignjustify.png new file mode 100644 index 0000000000..5721bf0fab Binary files /dev/null and b/api/templates/default/images/htmlarea/alignjustify.png differ diff --git a/api/templates/default/images/htmlarea/alignjustify.svg b/api/templates/default/images/htmlarea/alignjustify.svg new file mode 100644 index 0000000000..56b332be44 --- /dev/null +++ b/api/templates/default/images/htmlarea/alignjustify.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/alignleft.png b/api/templates/default/images/htmlarea/alignleft.png new file mode 100644 index 0000000000..500b449edc Binary files /dev/null and b/api/templates/default/images/htmlarea/alignleft.png differ diff --git a/api/templates/default/images/htmlarea/alignleft.svg b/api/templates/default/images/htmlarea/alignleft.svg new file mode 100644 index 0000000000..93731ac1ce --- /dev/null +++ b/api/templates/default/images/htmlarea/alignleft.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/alignright.png b/api/templates/default/images/htmlarea/alignright.png new file mode 100644 index 0000000000..00f3cbeff8 Binary files /dev/null and b/api/templates/default/images/htmlarea/alignright.png differ diff --git a/api/templates/default/images/htmlarea/alignright.svg b/api/templates/default/images/htmlarea/alignright.svg new file mode 100644 index 0000000000..fc0cb56585 --- /dev/null +++ b/api/templates/default/images/htmlarea/alignright.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/backcolor.png b/api/templates/default/images/htmlarea/backcolor.png new file mode 100644 index 0000000000..0ce3fc50b7 Binary files /dev/null and b/api/templates/default/images/htmlarea/backcolor.png differ diff --git a/api/templates/default/images/htmlarea/backcolor.svg b/api/templates/default/images/htmlarea/backcolor.svg new file mode 100644 index 0000000000..f32afe7e0c --- /dev/null +++ b/api/templates/default/images/htmlarea/backcolor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/api/templates/default/images/htmlarea/bold.png b/api/templates/default/images/htmlarea/bold.png new file mode 100644 index 0000000000..aded427530 Binary files /dev/null and b/api/templates/default/images/htmlarea/bold.png differ diff --git a/api/templates/default/images/htmlarea/bold.svg b/api/templates/default/images/htmlarea/bold.svg new file mode 100644 index 0000000000..a9437a5dc4 --- /dev/null +++ b/api/templates/default/images/htmlarea/bold.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/bullist.png b/api/templates/default/images/htmlarea/bullist.png new file mode 100644 index 0000000000..2255660f2e Binary files /dev/null and b/api/templates/default/images/htmlarea/bullist.png differ diff --git a/api/templates/default/images/htmlarea/bullist.svg b/api/templates/default/images/htmlarea/bullist.svg new file mode 100644 index 0000000000..f9f86e6d0e --- /dev/null +++ b/api/templates/default/images/htmlarea/bullist.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/code.png b/api/templates/default/images/htmlarea/code.png new file mode 100644 index 0000000000..88fa77a806 Binary files /dev/null and b/api/templates/default/images/htmlarea/code.png differ diff --git a/api/templates/default/images/htmlarea/code.svg b/api/templates/default/images/htmlarea/code.svg new file mode 100644 index 0000000000..50534df848 --- /dev/null +++ b/api/templates/default/images/htmlarea/code.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/forecolor.png b/api/templates/default/images/htmlarea/forecolor.png new file mode 100644 index 0000000000..bc0b74df66 Binary files /dev/null and b/api/templates/default/images/htmlarea/forecolor.png differ diff --git a/api/templates/default/images/htmlarea/forecolor.svg b/api/templates/default/images/htmlarea/forecolor.svg new file mode 100644 index 0000000000..90f824d5ee --- /dev/null +++ b/api/templates/default/images/htmlarea/forecolor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/api/templates/default/images/htmlarea/image.png b/api/templates/default/images/htmlarea/image.png new file mode 100644 index 0000000000..4652392ac0 Binary files /dev/null and b/api/templates/default/images/htmlarea/image.png differ diff --git a/api/templates/default/images/htmlarea/image.svg b/api/templates/default/images/htmlarea/image.svg new file mode 100644 index 0000000000..4dce6ccad4 --- /dev/null +++ b/api/templates/default/images/htmlarea/image.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/indent.png b/api/templates/default/images/htmlarea/indent.png new file mode 100644 index 0000000000..1a257718b1 Binary files /dev/null and b/api/templates/default/images/htmlarea/indent.png differ diff --git a/api/templates/default/images/htmlarea/indent.svg b/api/templates/default/images/htmlarea/indent.svg new file mode 100644 index 0000000000..f5a30272bf --- /dev/null +++ b/api/templates/default/images/htmlarea/indent.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/italic.png b/api/templates/default/images/htmlarea/italic.png new file mode 100644 index 0000000000..a0f5691615 Binary files /dev/null and b/api/templates/default/images/htmlarea/italic.png differ diff --git a/api/templates/default/images/htmlarea/italic.svg b/api/templates/default/images/htmlarea/italic.svg new file mode 100644 index 0000000000..58f1e077a5 --- /dev/null +++ b/api/templates/default/images/htmlarea/italic.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/link.png b/api/templates/default/images/htmlarea/link.png new file mode 100644 index 0000000000..a573571fa2 Binary files /dev/null and b/api/templates/default/images/htmlarea/link.png differ diff --git a/api/templates/default/images/htmlarea/link.svg b/api/templates/default/images/htmlarea/link.svg new file mode 100644 index 0000000000..fe5d954315 --- /dev/null +++ b/api/templates/default/images/htmlarea/link.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/ltr.png b/api/templates/default/images/htmlarea/ltr.png new file mode 100644 index 0000000000..0a608a8ef5 Binary files /dev/null and b/api/templates/default/images/htmlarea/ltr.png differ diff --git a/api/templates/default/images/htmlarea/ltr.svg b/api/templates/default/images/htmlarea/ltr.svg new file mode 100644 index 0000000000..d38f983830 --- /dev/null +++ b/api/templates/default/images/htmlarea/ltr.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/numlist.png b/api/templates/default/images/htmlarea/numlist.png new file mode 100644 index 0000000000..fdb112826b Binary files /dev/null and b/api/templates/default/images/htmlarea/numlist.png differ diff --git a/api/templates/default/images/htmlarea/numlist.svg b/api/templates/default/images/htmlarea/numlist.svg new file mode 100644 index 0000000000..8ebc051372 --- /dev/null +++ b/api/templates/default/images/htmlarea/numlist.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/outdent.png b/api/templates/default/images/htmlarea/outdent.png new file mode 100644 index 0000000000..806c7fe7fb Binary files /dev/null and b/api/templates/default/images/htmlarea/outdent.png differ diff --git a/api/templates/default/images/htmlarea/outdent.svg b/api/templates/default/images/htmlarea/outdent.svg new file mode 100644 index 0000000000..6ee05cd7d4 --- /dev/null +++ b/api/templates/default/images/htmlarea/outdent.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/redo.png b/api/templates/default/images/htmlarea/redo.png new file mode 100644 index 0000000000..a1c8a6ec24 Binary files /dev/null and b/api/templates/default/images/htmlarea/redo.png differ diff --git a/api/templates/default/images/htmlarea/removeformat.png b/api/templates/default/images/htmlarea/removeformat.png new file mode 100644 index 0000000000..1441a5d748 Binary files /dev/null and b/api/templates/default/images/htmlarea/removeformat.png differ diff --git a/api/templates/default/images/htmlarea/removeformat.svg b/api/templates/default/images/htmlarea/removeformat.svg new file mode 100644 index 0000000000..ee9a91aa2c --- /dev/null +++ b/api/templates/default/images/htmlarea/removeformat.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/rtl.png b/api/templates/default/images/htmlarea/rtl.png new file mode 100644 index 0000000000..f7791265f0 Binary files /dev/null and b/api/templates/default/images/htmlarea/rtl.png differ diff --git a/api/templates/default/images/htmlarea/rtl.svg b/api/templates/default/images/htmlarea/rtl.svg new file mode 100644 index 0000000000..1d193889e0 --- /dev/null +++ b/api/templates/default/images/htmlarea/rtl.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/searchreplace.png b/api/templates/default/images/htmlarea/searchreplace.png new file mode 100644 index 0000000000..6554bbfa3b Binary files /dev/null and b/api/templates/default/images/htmlarea/searchreplace.png differ diff --git a/api/templates/default/images/htmlarea/searchreplace.svg b/api/templates/default/images/htmlarea/searchreplace.svg new file mode 100644 index 0000000000..54daebb1c9 --- /dev/null +++ b/api/templates/default/images/htmlarea/searchreplace.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/strikethrough.png b/api/templates/default/images/htmlarea/strikethrough.png new file mode 100644 index 0000000000..5a7be08f1b Binary files /dev/null and b/api/templates/default/images/htmlarea/strikethrough.png differ diff --git a/api/templates/default/images/htmlarea/strikethrough.svg b/api/templates/default/images/htmlarea/strikethrough.svg new file mode 100644 index 0000000000..91634c15f9 --- /dev/null +++ b/api/templates/default/images/htmlarea/strikethrough.svg @@ -0,0 +1 @@ + diff --git a/api/templates/default/images/htmlarea/undo.png b/api/templates/default/images/htmlarea/undo.png new file mode 100644 index 0000000000..c502d2a636 Binary files /dev/null and b/api/templates/default/images/htmlarea/undo.png differ diff --git a/api/templates/default/images/htmlarea/undo.svg b/api/templates/default/images/htmlarea/undo.svg new file mode 100644 index 0000000000..1505b968f8 --- /dev/null +++ b/api/templates/default/images/htmlarea/undo.svg @@ -0,0 +1 @@ + diff --git a/preferences/inc/class.preferences_hooks.inc.php b/preferences/inc/class.preferences_hooks.inc.php index 846171ade6..deae04e31c 100644 --- a/preferences/inc/class.preferences_hooks.inc.php +++ b/preferences/inc/class.preferences_hooks.inc.php @@ -115,6 +115,24 @@ class preferences_hooks $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size'], $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_unit']); } + $rte_toolbar_list = array ( + 'undo', 'redo', 'formatselect', 'fontselect', 'fontsizeselect', + 'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor', + 'link', 'alignleft', 'aligncenter', 'alignright', 'alignjustify', + 'numlist', 'bullist', 'outdent', 'indent', 'ltr', 'rtl', + 'removeformat', 'code', 'image', 'searchreplace' + ); + $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.'.png', + 'app' => 'api' + ); + } // Settings array for this app $settings = array( array( @@ -408,6 +426,21 @@ class preferences_hooks 'admin' => false, 'default'=> 'extended' ), + 'rte_toolbar' => array( + 'type' => 'taglist', + 'label' => 'Enabled features in toolbar', + 'name' => 'rte_toolbar', + 'values'=> '', + 'help' => 'You may select features to be enabled in toolbar. Selecting any of the tools from here means seleted "Feature of the editor" preference would be ignored.', + 'admin' => true, + 'attributes' => array( + 'allowFreeEntries' => false, + //'multiple' => 'toggle', + 'editModeEnabled' => false, + 'autocomplete_url' => ' ', + 'select_options' => $rte_toolbar_selOptions + ) + ) ); // disable thumbnails, if no size configured by admin if (!$GLOBALS['egw_info']['server']['link_list_thumbnail']) unset($settings['link_list_thumbnail']);