getToolbarItems example

return $this->drupal['toolbar_items'];
  }

  /** * Whether this plugin has toolbar items. * * @return bool * * @see \Drupal\ckeditor5\Annotation\DrupalAspectsOfCKEditor5Plugin::$toolbar_items */
  public function hasToolbarItems(): bool {
    return $this->getToolbarItems() !== [];
  }

  /** * Gets the asset library this plugin needs to be loaded. * * @return string * An asset library ID. * * @see \Drupal\ckeditor5\Annotation\DrupalAspectsOfCKEditor5Plugin::$library * * @throws \LogicException * When called on a plugin definition that has no library. */
->setParameter('%plugin', $plugin_definition->label())
          ->setParameter('@attributes_on_tag', implode(', ', $attributes_on_tag->toCKEditor5ElementsArray()));

        // If this plugin has a configurable subset, associate the violation         // with the property path pointing to this plugin's settings form.         if (is_a($plugin_definition->getClass(), CKEditor5PluginElementsSubsetInterface::class, TRUE)) {
          $violation->atPath(sprintf('settings.plugins.%s', $plugin_definition->id()));
        }
        // If this plugin is associated with a toolbar item, associate the         // violation with the property path pointing to the active toolbar item.         elseif ($plugin_definition->hasToolbarItems()) {
          $toolbar_items = $plugin_definition->getToolbarItems();
          $active_toolbar_items = array_intersect(
            $text_editor->getSettings()['toolbar']['items'],
            array_keys($toolbar_items)
          );
          $violation->atPath(sprintf('settings.toolbar.items.%d', array_keys($active_toolbar_items)[0]));
        }

        $violation->addViolation();
      }
    }
  }

  
$enabled_for_tags_message_content = '';
        $enabled_for_attributes_message_content = '';
        $editor_settings_to_update = $editor->getSettings();
        // Create new group for all the added toolbar items.         $editor_settings_to_update['toolbar']['items'][] = '|';
        foreach ($selected_plugins as $plugin_id => $reason_why_enabled) {
          $plugin_definition = $this->pluginManager->getDefinition($plugin_id);
          $label = $plugin_definition->label();
          $plugins_enabled[] = $label;
          if ($plugin_definition->hasToolbarItems()) {
            [$net_new] = self::computeNetNewElementsForPlugin($provided$still_needed$plugin_definition);
            $editor_settings_to_update['toolbar']['items'] = array_merge($editor_settings_to_update['toolbar']['items']array_keys($plugin_definition->getToolbarItems()));
            foreach ($reason_why_enabled as $attribute_name => $attribute_config) {
              // Plugin was selected for tag.               if (in_array($attribute_name['-attributes-none-', '-attributes-any-'], TRUE)) {
                $tags = array_reduce(array_keys($net_new->getAllowedElements())function D$carry$item) {
                  return $carry . "<$item>";
                });
                $enabled_for_tags_message_content .= "$label (for tags: $tags) ";
                // This plugin does not add attributes: continue to next plugin.                 continue;
              }
              // Plugin was selected for attribute.


    // The items are encoded in markup to provide a no-JS fallback.     // Although CKEditor 5 is useless without JS it would still be possible     // to see all the available toolbar items provided by plugins in the format     // that needs to be entered in the textarea. The UI app parses this list.     $form['toolbar']['available'] = [
      '#type' => 'container',
      '#title' => 'Available items',
      '#id' => 'ckeditor5-toolbar-buttons-available',
      'available_items' => [
        '#markup' => Json::encode($this->ckeditor5PluginManager->getToolbarItems()),
      ],
    ];

    $editor_settings = $editor->getSettings();
    // This form field requires a JSON-style array of valid toolbar items.     // e.g. ["bold","italic","|","drupalInsertImage"].     // CKEditor 5 config for toolbar items takes an array of strings which     // correspond to the keys under toolbar_items in a plugin yml or annotation.     // @see https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html     $form['toolbar']['items'] = [
      '#type' => 'textarea',
      
// The `plugins` condition can only be evaluated at the end of           // gathering enabled definitions. ::isPluginDisabled() did not yet           // evaluate that condition.           if (array_key_exists('plugins', $definition->getConditions())) {
            $definitions_with_plugins_condition[$plugin_id] = $definition;
          }
        }
      }
      // Otherwise, only remove the definition if the plugin has buttons and       // none of its buttons are active.       elseif ($definition->hasToolbarItems()) {
        if (empty(array_intersect($editor->getSettings()['toolbar']['items']array_keys($definition->getToolbarItems())))) {
          unset($definitions[$plugin_id]);
        }
      }
    }

    // Only enable the arbitrary HTML Support plugin on text formats with no     // HTML restrictions.     // @see https://ckeditor.com/docs/ckeditor5/latest/api/html-support.html     // @see https://github.com/ckeditor/ckeditor5/issues/9856     if ($editor->getFilterFormat()->getHtmlRestrictions() !== FALSE) {
      unset($definitions['ckeditor5_arbitraryHtmlSupport']);
    }
    // @see https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html#separating-toolbar-items     if ($toolbar_item === '|') {
      return TRUE;
    }

    // Special case: the breakpoint separator.     // @see https://ckeditor.com/docs/ckeditor5/latest/features/toolbar/toolbar.html#explicit-wrapping-breakpoint     if ($toolbar_item === '-') {
      return TRUE;
    }

    $available_toolbar_items = array_keys($this->pluginManager->getToolbarItems());
    return in_array($toolbar_item$available_toolbar_items, TRUE);
  }

}
// No plugin definition found for this toolbar item. It's the       // responsibility of another validation constraint to raise this problem.       // @see \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraint       return;
    }

    // If there are no conditions, there is nothing to validate.     if (!$definition->hasConditions()) {
      return;
    }

    $toolbar_item_label = $definition->getToolbarItems()[$toolbar_item]['label'];
    $text_editor = $this->createTextEditorObjectFromContext();

    $conditions = $definition->getConditions();
    foreach ($conditions as $condition_type => $required_value) {
      switch ($condition_type) {
        case 'toolbarItem':
          // Nothing to validate.           break;

        case 'imageUploadStatus':
          $image_upload_settings = $text_editor->getImageUploadSettings();
          
Home | Imprint | This part of the site doesn't use cookies.