From 39944322b5fd58c9c43ba80b4bf8a04679e15dba Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 25 Oct 2018 12:32:18 +0200 Subject: [PATCH] W.I.P. implementing TinyMCE editor and deprecating CKEditor: - Replace fckEditor with tinymce for old etemplate apps --- api/src/Html.php | 106 ++++++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 43 deletions(-) diff --git a/api/src/Html.php b/api/src/Html.php index 4eb8ebd5d0..791e2c8e13 100644 --- a/api/src/Html.php +++ b/api/src/Html.php @@ -13,7 +13,7 @@ */ namespace EGroupware\Api; - +use EGroupware\Api\Header\ContentSecurityPolicy; /** * Generates html with methods representing html-tags or higher widgets * @@ -448,62 +448,82 @@ class Html } //include the ckeditor js file - Framework::includeJS('/vendor/egroupware/ckeditor/ckeditor.js'); + Framework::includeJS('/api/js/tinymce/tinymce.min.js'); // run content through htmlpurifier if ($_purify && !empty($_content)) $_content = self::purify($_content); - // By default the editor start expanded - $expanded = isset($_options['toolbar_expanded']) ? - $_options['toolbar_expanded'] == 'true' : true; - - //Get the height in pixels from the pixels parameter - $pxheight = (strpos('px', $_height) === false) ? - (empty($_height) ? 400 : $_height) : str_replace('px', '', $_height); - // User preferences $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; - $font_size = Html\CkEditorConfig::font_size_from_prefs(); - $font_span = ''; - if (empty($font) && empty($font_size)) $font_span = ''; - + $font_size = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_size']; + $font_size_unit = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_unit']; + $rte_menubar = $GLOBALS['egw_info']['user']['preferences']['common']['rte_menubar']; + $focusToBody = $_focusToBody ? "tinymce" : false; + ContentSecurityPolicy::add('script-src', 'unsafe-inline'); // we need to enable double encoding here, as ckEditor has to undo one level of encoding // otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html! //error_log(__METHOD__.__LINE__.' '.Header\UserAgent::type().','.Header\UserAgent::version()); return self::textarea($_name,$_content,'id="'.htmlspecialchars($_name).'"',true). // true = double encoding ' '; }