Default textarea buttons inside structure modal

Since it’s not possible to open a modal inside a modal, the default textarea field hides all buttons except for the “bold” and “italic”. That has been discussed multiple times already.

But where exactly does the textarea field define that?

I try to add some default buttons to my enhanced textarea and couldn’t find the function that say something like “do not show button if something else than bold or italic”. Since it’s relatively easy to extend the default textarea with custom buttons, these should probably be visible in the structure modal by default. Only if they open a modal with the “action” value defined in buttons.php they should be hidden.

This happens outside of the textarea or structure fields in /panel/app/src/panel/structure.php:

foreach($fields as $name => $field) {

      // remove all structure fields within structures
      if($field['type'] == 'structure') {
        unset($fields[$name]);
      // convert title fields to normal text fields
      } else if($field['type'] == 'title') {
        $fields[$name]['type'] = 'text';
      // remove invalid buttons from textareas
      } else if($field['type'] == 'textarea') {
        $buttons = a::get($fields[$name], 'buttons');
        if(is_array($buttons)) {
          foreach($buttons as $index => $value) {
            if(in_array($value, array('link','email'))) {
              unset($fields[$name]['buttons'][$index]);              
            }
          }
        } else if($buttons !== false) {
          $fields[$name]['buttons'] = array('bold', 'italic');
        }
      }

    }

Alright, thank you @texnixe!

Shouldn’t this be “if opens modal” instead of “in_array($value, array(‘link’,‘email’))”? As I wrote in my initial post, it’s relatively easy and useful to extend the textarea. And it should be possible to check wether the “action” value is defined.

Yes, I think it would be much more useful if the fields not to use were not hardcoded like this. I suggest you create a feature request issue on GitHub. For the time being you could probably work around this issue by defining the buttons to use in the field if it is within a structure field or hide them via javascript?

I’d totally love to see this btw.

@daybugging The buttons inside of a structure field modal? That’s one of the features of the SimpleMDE field.