previously code expected to find the button in particular row but the tinymce setting may change the buttons' layout
}
}
- // Add button before 'nonbreaking' in advancedbuttons3.
- $this->add_button_before($params, 3, 'dragmath', 'nonbreaking');
+ if ($row = $this->find_button($params, 'nonbreaking')) {
+ // Add button before 'nonbreaking'.
+ $this->add_button_before($params, $row, 'dragmath', 'nonbreaking');
+ } else {
+ // If 'nonbreaking' is not found, add button in the end of the last row:
+ $this->add_button_after($params, $this->count_button_rows($params), 'dragmath');
+ }
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
}
- // Add button after 'image' in advancedbuttons3.
- $this->add_button_after($params, 3, 'moodleemoticon', 'image');
+ if ($row = $this->find_button($params, 'image')) {
+ // Add button after 'image'.
+ $this->add_button_after($params, $row, 'moodleemoticon', 'image');
+ } else {
+ // If 'image' is not found, add button in the end of the last row.
+ $this->add_button_after($params, $this->count_button_rows($params), 'moodleemoticon');
+ }
// Add JS file, which uses default name.
$this->add_js_plugin($params);
}
}
- // Add button after emoticon button in advancedbuttons1.
- $added = $this->add_button_after($params, 1, 'moodlemedia', 'moodleemoticon', false);
-
- // Note: We know that the emoticon button has already been added, if it
- // exists, because I set the sort order higher for this. So, if no
- // emoticon, add after 'image'.
- if (!$added) {
- $this->add_button_after($params, 1, 'moodlemedia', 'image');
+ if ($row = $this->find_button($params, 'moodleemoticon')) {
+ // Add button after 'moodleemoticon' icon.
+ $this->add_button_after($params, $row, 'moodlemedia', 'moodleemoticon');
+ } else if ($row = $this->find_button($params, 'image')) {
+ // Note: We know that the plugin emoticon button has already been added
+ // if it is enabled because this plugin has higher sortorder.
+ // Otherwise add after 'image'.
+ $this->add_button_after($params, $row, 'moodlemedia', 'image');
+ } else {
+ // Add this button in the end of the first row (by default 'image' button should be in the first row).
+ $this->add_button_after($params, 1, 'moodlemedia');
}
// Add JS file, which uses default name.
protected function update_init_params(array &$params, context $context,
array $options = null) {
- // Add button after 'unlink' in advancedbuttons1.
- $this->add_button_after($params, 1, 'moodlenolink', 'unlink');
+ if ($row = $this->find_button($params, 'unlink')) {
+ // Add button after 'unlink'.
+ $this->add_button_after($params, $row, 'moodlenolink', 'unlink');
+ } else {
+ // Add this button in the end of the first row (by default 'unlink' button should be in the first row).
+ $this->add_button_after($params, 1, 'moodlenolink');
+ }
// Add JS file, which uses default name.
$this->add_js_plugin($params);
// Prevent the built-in spell checker in Firefox, Safari and other sane browsers.
unset($params['gecko_spellcheck']);
- // Add button after code button in advancedbuttons3.
- $added = $this->add_button_after($params, 3, 'spellchecker', 'code', false);
+ if ($row = $this->find_button($params, 'code')) {
+ // Add button after 'code'.
+ $this->add_button_after($params, $row, 'spellchecker', 'code');
+ }
// Add JS file, which uses default name.
$this->add_js_plugin($params);