getCreatableElements example

            if ($editor->isNew()) {
              $subset = [];
            }
            else {
              throw new \LogicException(sprintf('The "%s" CKEditor 5 plugin implements ::getElementsSubset() and did not return a subset, the following tags are absent from the plugin definition: "%s".', $idimplode(' ', $not_in_max_supported->toCKEditor5ElementsArray())));
            }
          }

          // Also detect what is technically a valid subset, but has lost the           // ability to create tags that are still in the subset. This points to           // a bug in the plugin's ::getElementsSubset() logic.           $defined_creatable = HTMLRestrictions::fromString(implode($definition->getCreatableElements()));
          $subset_creatable_actual = HTMLRestrictions::fromString(implode(array_filter($subset[CKEditor5PluginDefinition::class, 'isCreatableElement'])));
          $subset_creatable_needed = $subset_restrictions->extractPlainTagsSubset()
            ->intersect($defined_creatable);
          $missing_creatable_for_subset = $subset_creatable_needed->diff($subset_creatable_actual);
          if (!$missing_creatable_for_subset->allowsNothing()) {
            throw new \LogicException(sprintf('The "%s" CKEditor 5 plugin implements ::getElementsSubset() and did return a subset ("%s") but the following tags can no longer be created: "%s".', $idimplode($subset_restrictions->toCKEditor5ElementsArray())implode($missing_creatable_for_subset->toCKEditor5ElementsArray())));
          }

          $defined_elements = $subset;
        }
      }
      
$plugin_candidates = [];
    if (!$still_needed->allowsNothing()) {
      foreach ($disabled_plugin_definitions as $definition) {
        // Only proceed if the plugin has configured elements and the plugin         // does not have conditions. In the future we could add support for         // automatically enabling filters, but for now we assume that the filter         // configuration cannot be modified.         if (!$definition->hasConditions() && $definition->hasElements()) {
          [$net_new$surplus_additions] = self::computeNetNewElementsForPlugin($provided$still_needed$definition);
          if (!$net_new->allowsNothing()) {
            $plugin_id = $definition->id();
            $creatable_elements = HTMLRestrictions::fromString(implode(' ', $definition->getCreatableElements()));
            $surplus_score = static::computeSurplusScore($surplus_additions$still_needed);
            foreach ($net_new->getAllowedElements() as $tag_name => $attributes_config) {
              // Non-specific attribute restrictions: `FALSE` or `TRUE`.               // TRICKY: PHP does not support boolean array keys, so map these               // to a string. The string must not be a valid attribute name, so               // use a leading and trailing dash.               if (!is_array($attributes_config)) {
                if ($attributes_config === FALSE && !array_key_exists($tag_name$creatable_elements->getAllowedElements())) {
                  // If this plugin is not able to create the plain tag, then                   // cannot be a candidate for the tag without attributes.                   continue;
                }
Home | Imprint | This part of the site doesn't use cookies.