You are here

function _insert_allowed_html_validate in Insert 8.2

Parameters

array $element:

\Drupal\Core\Form\FormStateInterface $form_state:

1 string reference to '_insert_allowed_html_validate'
insert_form_alter in ./insert.module
Implements hook_form_alter().

File

./insert.module, line 844

Code

function _insert_allowed_html_validate(array $element, FormStateInterface &$form_state) {
  $tags = [
    'img' => NULL,
    'a' => NULL,
    'audio' => NULL,
    'span' => NULL,
    'video' => NULL,
  ];
  $attributes = [
    'img' => [
      'class' => NULL,
      'src' => NULL,
      'width' => NULL,
      'height' => NULL,
      'alt' => NULL,
      'title' => NULL,
    ],
    'a' => [
      'class' => NULL,
      'title' => NULL,
      'type' => NULL,
    ],
    'audio' => [
      // Although added through insert_editor_js_settings_alter, CKEditor does
      // not accept contenteditable on <audio> and <video> if not explicitly
      // white-listed:
      'contenteditable' => NULL,
      'controls' => NULL,
      'src' => NULL,
      'type' => NULL,
    ],
    'span' => [
      'class' => NULL,
    ],
    'video' => [
      'contenteditable' => NULL,
      'controls' => NULL,
      'src' => NULL,
      'type' => NULL,
    ],
  ];
  $additional = \Drupal::moduleHandler()
    ->invokeAll('insert_allowed_html');
  $form_state
    ->setValueForElement($element, InsertUtility::addAllowedHtml($element['#value'], NestedArray::mergeDeep($tags, isset($additional['tags']) ? $additional['tags'] : []), NestedArray::mergeDeep($attributes, isset($additional['attributes']) ? $additional['attributes'] : [])));
}