From 96354be5ec4002f4687b2250d57166c23adaa8a8 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 14 Jul 2022 13:22:48 -0600 Subject: [PATCH] Get text editor toolbar preference working with webcomponents --- api/src/Etemplate/Widget/HtmlArea.php | 27 ++++++++++--------- .../inc/class.preferences_hooks.inc.php | 19 +++++-------- .../inc/class.preferences_settings.inc.php | 6 ++++- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/api/src/Etemplate/Widget/HtmlArea.php b/api/src/Etemplate/Widget/HtmlArea.php index 3fa18f64a7..27b2b6ee2e 100644 --- a/api/src/Etemplate/Widget/HtmlArea.php +++ b/api/src/Etemplate/Widget/HtmlArea.php @@ -105,26 +105,29 @@ class HtmlArea extends Etemplate\Widget * Create an array of toolbar as sel options * * @return array - * [ - * id => {string} - * label => {string} - * title => {string} - * icon => {string} - * app => {string} - * ] + * [ + * id => {string} + * value => {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) { - $file = '/api/templates/default/images/htmlarea/'.$toolbar.'.svg'; - $toolbar_selOptions[$toolbar] = array ( - 'id' => $toolbar, + $file = '/api/templates/default/images/htmlarea/' . $toolbar . '.svg'; + $toolbar_selOptions[$toolbar] = array( + 'id' => $toolbar, + // Selectbox validation can't understand all these options without value + 'value' => $toolbar, 'label' => lang($toolbar), 'title' => lang($toolbar), - 'icon' => file_exists(EGW_SERVER_ROOT.$file)?Api\Framework::getUrl($GLOBALS['egw_info']['server']['webserver_url'].$file):'', - 'app' => 'api' + 'icon' => file_exists(EGW_SERVER_ROOT . $file) ? Api\Framework::getUrl($GLOBALS['egw_info']['server']['webserver_url'] . $file) : '', + 'app' => 'api' ); } return $toolbar_selOptions; diff --git a/preferences/inc/class.preferences_hooks.inc.php b/preferences/inc/class.preferences_hooks.inc.php index 5c43015bb1..1a902abb04 100644 --- a/preferences/inc/class.preferences_hooks.inc.php +++ b/preferences/inc/class.preferences_hooks.inc.php @@ -456,19 +456,12 @@ class preferences_hooks 'default' => '1', ), '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' => Api\Etemplate\Widget\HtmlArea::get_toolbar_as_selOptions() - ) + 'type' => 'taglist', + 'label' => 'Enabled features in toolbar', + 'name' => 'rte_toolbar', + 'values' => Api\Etemplate\Widget\HtmlArea::get_toolbar_as_selOptions(), + '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 ) ); // disable thumbnails, if no size configured by admin diff --git a/preferences/inc/class.preferences_settings.inc.php b/preferences/inc/class.preferences_settings.inc.php index c52aa9a238..60d6454be8 100644 --- a/preferences/inc/class.preferences_settings.inc.php +++ b/preferences/inc/class.preferences_settings.inc.php @@ -479,6 +479,7 @@ class preferences_settings $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'autocomplete_url', ''); } $setting['type'] = 'et2-select'; + $setting['multiple'] = true; $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', true); break; } @@ -532,7 +533,10 @@ class preferences_settings 'onchange' => $setting['onchange'] ); - // 'attributes' => $setting['attributes'] + foreach($setting['attributes'] as $attr => $attr_value) + { + $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', $attr, $attr_value); + } //error_log("appname=$appname, attribute=$attribute, setting=".array2string($setting)); $content[$tab][$setting['name']] = $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']]; //if ($old_type == 'multiselect') $content[$tab][$setting['name']] = explode(',', $content[$tab][$setting['name']]);