mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 23:42:11 +02:00
MDL-37186 add the ultimate TinyMCE custom parameter setting
This commit is contained in:
parent
0dc5a532ec
commit
23ac6ef6c5
@ -246,3 +246,30 @@ class tiynce_subplugins_settings extends admin_setting {
|
||||
return highlight($query, $return);
|
||||
}
|
||||
}
|
||||
|
||||
class editor_tinymce_json_setting_textarea extends admin_setting_configtextarea {
|
||||
/**
|
||||
* Returns an XHTML string for the editor
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $query
|
||||
* @return string XHTML string for the editor
|
||||
*/
|
||||
public function output_html($data, $query='') {
|
||||
$result = parent::output_html($data, $query);
|
||||
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
$decoded = json_decode($data, true);
|
||||
// Note: it is not very nice to abuse these file classes, but anyway...
|
||||
if (is_array($decoded)) {
|
||||
$valid = '<span class="pathok">✔</span>';
|
||||
} else {
|
||||
$valid = '<span class="patherror">✘</span>';
|
||||
}
|
||||
$result = str_replace('</textarea>', '</textarea>'.$valid, $result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
//== Custom Moodle strings that are not part of upstream TinyMCE ==
|
||||
$string['availablebuttons'] = 'Available buttons';
|
||||
$string['customconfig'] = 'Custom configuration';
|
||||
$string['customconfig_desc'] = 'Custom advanced TinyMCE configuration in JSON format, for example: {"option1" : "value2", "option2" : "value2"}. Any options specified here override standard and plugin settings.';
|
||||
$string['customtoolbar'] = 'Editor toolbar';
|
||||
$string['customtoolbar_desc'] = 'Each line contains a list of comma separated button names, use "|" as a group separator, empty lines are ignored. See <a href="{$a}" target="_blank">{$a}</a> for the list of default TinyMCE buttons.';
|
||||
$string['fontselectlist'] = 'Available fonts list';
|
||||
|
@ -184,6 +184,16 @@ class tinymce_texteditor extends texteditor {
|
||||
$params['theme_advanced_buttons1'] = '';
|
||||
}
|
||||
|
||||
if (!empty($config->customconfig)) {
|
||||
$config->customconfig = trim($config->customconfig);
|
||||
$decoded = json_decode($config->customconfig, true);
|
||||
if (is_array($decoded)) {
|
||||
foreach ($decoded as $k=>$v) {
|
||||
$params[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted'])) {
|
||||
// now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
|
||||
// but they scream even more when we strip all tags that are not strict :-(
|
||||
|
@ -40,7 +40,9 @@ bullist,numlist,outdent,indent,|,link,unlink,|,image,nonbreaking,charmap,table,|
|
||||
get_string('customtoolbar', 'editor_tinymce'), get_string('customtoolbar_desc', 'editor_tinymce', 'http://www.tinymce.com/wiki.php/Buttons/controls'), $default, PARAM_RAW, 100, 8));
|
||||
$settings->add(new admin_setting_configtextarea('editor_tinymce/fontselectlist',
|
||||
get_string('fontselectlist', 'editor_tinymce'), '',
|
||||
'Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings', PARAM_RAW));
|
||||
'Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings', PARAM_RAW, 100, 8));
|
||||
$settings->add(new editor_tinymce_json_setting_textarea('editor_tinymce/customconfig',
|
||||
get_string('customconfig', 'editor_tinymce'), get_string('customconfig_desc', 'editor_tinymce'), '', PARAM_RAW, 100, 8));
|
||||
}
|
||||
$ADMIN->add('editortinymce', $settings);
|
||||
unset($settings);
|
||||
|
Loading…
x
Reference in New Issue
Block a user