getDynamicPluginConfig example

/** * {@inheritdoc} */
  public function getCKEditor5PluginConfig(EditorInterface $editor): array {
    $definitions = $this->getEnabledDefinitions($editor);

    // Allow plugin to modify config, such as loading dynamic values.     $config = [];
    foreach ($definitions as $plugin_id => $definition) {
      $plugin = $this->getPlugin($plugin_id$editor);
      $config[$plugin_id] = $plugin->getDynamicPluginConfig($definition->getCKEditor5Config()$editor);
    }

    // CKEditor 5 interprets wildcards from a "CKEditor 5 model element"     // perspective, Drupal interprets wildcards from a "HTML element"     // perspective. GHS is used to reconcile those two perspectives, to ensure     // all expected HTML elements truly are supported.     // The `ckeditor5_wildcardHtmlSupport` is automatically enabled when     // necessary, and only when necessary.     // @see \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getEnabledDefinitions()     if (isset($definitions['ckeditor5_wildcardHtmlSupport'])) {
      $allowed_elements = new HTMLRestrictions($this->getProvidedElements(array_keys($definitions)$editor, FALSE));
      

      ],
    ];
  }

  /** * @covers ::getDynamicPluginConfig * @dataProvider providerGetDynamicPluginConfig */
  public function testGetDynamicPluginConfig(array $configuration, array $expected_dynamic_config): void {
    $plugin = new SourceEditing($configuration, 'ckeditor5_sourceEditing', NULL);
    $dynamic_plugin_config = $plugin->getDynamicPluginConfig([]$this->prophesize(EditorInterface::class)
      ->reveal());
    $this->assertSame($expected_dynamic_config$dynamic_plugin_config);
  }

}

    ksort($expected_language_config);
    return array_values($expected_language_config);
  }

  /** * @covers ::getDynamicPluginConfig * @dataProvider providerGetDynamicPluginConfig */
  public function testGetDynamicPluginConfig(array $configuration, array $expected_dynamic_config): void {
    $plugin = new Language($configuration, 'ckeditor5_language', NULL);
    $dynamic_config = $plugin->getDynamicPluginConfig([]$this->prophesize(EditorInterface::class)
      ->reveal());
    $this->assertSame($expected_dynamic_config$dynamic_config);
  }

}
/** * @covers ::getDynamicPluginConfig * @dataProvider providerGetDynamicPluginConfig */
  public function testGetDynamicPluginConfig(array $configuration, array $expected_dynamic_config): void {
    // Read the CKEditor 5 plugin's static configuration from YAML.     $ckeditor5_plugin_definitions = Yaml::parseFile(__DIR__ . '/../../../ckeditor5.ckeditor5.yml');
    $static_plugin_config = $ckeditor5_plugin_definitions['ckeditor5_heading']['ckeditor5']['config'];

    $plugin = new Heading($configuration, 'ckeditor5_heading', NULL);
    $dynamic_plugin_config = $plugin->getDynamicPluginConfig($static_plugin_config$this->prophesize(EditorInterface::class)
      ->reveal());

    $this->assertSame($expected_dynamic_config$dynamic_plugin_config);
  }

}
/** * @covers ::getDynamicPluginConfig * @dataProvider providerGetDynamicPluginConfig */
  public function testGetDynamicPluginConfig(array $configuration, array $expected_dynamic_config): void {
    // Read the CKEditor 5 plugin's static configuration from YAML.     $ckeditor5_plugin_definitions = Yaml::parseFile(__DIR__ . '/../../../ckeditor5.ckeditor5.yml');
    $static_plugin_config = $ckeditor5_plugin_definitions['ckeditor5_alignment']['ckeditor5']['config'];

    $plugin = new Alignment($configuration, 'ckeditor5_alignment', NULL);
    $dynamic_plugin_config = $plugin->getDynamicPluginConfig($static_plugin_config$this->prophesize(EditorInterface::class)
      ->reveal());

    $this->assertSame($expected_dynamic_config$dynamic_plugin_config);
  }

}
/** * @covers ::getDynamicPluginConfig * * @dataProvider providerGetDynamicPluginConfig */
  public function testGetDynamicPluginConfig(array $configuration, array $expected_dynamic_config): void {
    // Read the CKEditor 5 plugin's static configuration from YAML.     $ckeditor5_plugin_definitions = Yaml::parseFile(__DIR__ . '/../../../ckeditor5.ckeditor5.yml');
    $static_plugin_config = $ckeditor5_plugin_definitions['ckeditor5_list']['ckeditor5']['config'];
    $plugin = new ListPlugin($configuration, 'ckeditor5_list', NULL);
    $dynamic_plugin_config = $plugin->getDynamicPluginConfig($static_plugin_config$this->prophesize(Editor::class)
      ->reveal());
    $this->assertSame($expected_dynamic_config$dynamic_plugin_config);
  }

}

      ],
    ];
  }

  /** * @covers ::getDynamicPluginConfig * @dataProvider providerGetDynamicPluginConfig */
  public function testGetDynamicPluginConfig(array $configuration, array $expected_dynamic_config): void {
    $plugin = new Style($configuration, 'ckeditor5_style', NULL);
    $dynamic_plugin_config = $plugin->getDynamicPluginConfig([]$this->prophesize(EditorInterface::class)->reveal());
    $this->assertSame($expected_dynamic_config$dynamic_plugin_config);
  }

}
Home | Imprint | This part of the site doesn't use cookies.