Get text editor toolbar preference working with webcomponents

This commit is contained in:
nathan 2022-07-14 13:22:48 -06:00
parent 53e5e45a5d
commit 96354be5ec
3 changed files with 26 additions and 26 deletions

View File

@ -105,26 +105,29 @@ class HtmlArea extends Etemplate\Widget
* Create an array of toolbar as sel options * Create an array of toolbar as sel options
* *
* @return array * @return array
* [ * [
* id => {string} * id => {string}
* label => {string} * value => {string}
* title => {string} * label => {string}
* icon => {string} * title => {string}
* app => {string} * icon => {string}
* ] * app => {string}
* ]
*/ */
public static function get_toolbar_as_selOptions () public static function get_toolbar_as_selOptions ()
{ {
$toolbar_selOptions = array(); $toolbar_selOptions = array();
foreach (self::$toolbar_list as $toolbar) foreach (self::$toolbar_list as $toolbar)
{ {
$file = '/api/templates/default/images/htmlarea/'.$toolbar.'.svg'; $file = '/api/templates/default/images/htmlarea/' . $toolbar . '.svg';
$toolbar_selOptions[$toolbar] = array ( $toolbar_selOptions[$toolbar] = array(
'id' => $toolbar, 'id' => $toolbar,
// Selectbox validation can't understand all these options without value
'value' => $toolbar,
'label' => lang($toolbar), 'label' => lang($toolbar),
'title' => lang($toolbar), 'title' => lang($toolbar),
'icon' => file_exists(EGW_SERVER_ROOT.$file)?Api\Framework::getUrl($GLOBALS['egw_info']['server']['webserver_url'].$file):'', 'icon' => file_exists(EGW_SERVER_ROOT . $file) ? Api\Framework::getUrl($GLOBALS['egw_info']['server']['webserver_url'] . $file) : '',
'app' => 'api' 'app' => 'api'
); );
} }
return $toolbar_selOptions; return $toolbar_selOptions;

View File

@ -456,19 +456,12 @@ class preferences_hooks
'default' => '1', 'default' => '1',
), ),
'rte_toolbar' => array( 'rte_toolbar' => array(
'type' => 'taglist', 'type' => 'taglist',
'label' => 'Enabled features in toolbar', 'label' => 'Enabled features in toolbar',
'name' => 'rte_toolbar', 'name' => 'rte_toolbar',
'values'=> '', '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.', '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, 'admin' => true
'attributes' => array(
'allowFreeEntries' => false,
//'multiple' => 'toggle',
'editModeEnabled' => false,
'autocomplete_url' => ' ',
'select_options' => Api\Etemplate\Widget\HtmlArea::get_toolbar_as_selOptions()
)
) )
); );
// disable thumbnails, if no size configured by admin // disable thumbnails, if no size configured by admin

View File

@ -479,6 +479,7 @@ class preferences_settings
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'autocomplete_url', ''); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'autocomplete_url', '');
} }
$setting['type'] = 'et2-select'; $setting['type'] = 'et2-select';
$setting['multiple'] = true;
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', true); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', true);
break; break;
} }
@ -532,7 +533,10 @@ class preferences_settings
'onchange' => $setting['onchange'] '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)); //error_log("appname=$appname, attribute=$attribute, setting=".array2string($setting));
$content[$tab][$setting['name']] = $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']]; $content[$tab][$setting['name']] = $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']];
//if ($old_type == 'multiselect') $content[$tab][$setting['name']] = explode(',', $content[$tab][$setting['name']]); //if ($old_type == 'multiselect') $content[$tab][$setting['name']] = explode(',', $content[$tab][$setting['name']]);