getEditorDataAsHtmlString example


  public function testConversion() {
    // Wrap the `<drupal-media>` markup in a `<p>`.     $original_value = $this->host->body->value;
    $this->host->body->value = '<p>foo' . $original_value . '</p>';
    $this->host->save();

    $this->drupalGet($this->host->toUrl('edit-form'));
    $this->waitForEditor();
    $assert_session = $this->assertSession();
    $assert_session->waitForElementVisible('css', 'img[src*="image-test.png"]', 1000);
    $editor_html = $this->getEditorDataAsHtmlString();
    // Observe that `<drupal-media>` was moved into its own block element.     $this->assertEquals('<p>foo</p>' . $original_valuestr_replace('&nbsp;', '', $editor_html));
  }

  /** * Tests that only <drupal-media> tags are processed. * * @see \Drupal\Tests\media\Kernel\MediaEmbedFilterTest::testOnlyDrupalMediaTagProcessed() */
  public function testOnlyDrupalMediaTagProcessed() {
    $original_value = $this->host->body->value;
    

trait CKEditor5TestTrait {

  /** * Gets CKEditor 5 instance data as a PHP DOMDocument. * * @return \DOMDocument * The result of parsing CKEditor 5's data into a PHP DOMDocument. */
  protected function getEditorDataAsDom(): \DOMDocument {
    return Html::load($this->getEditorDataAsHtmlString());
  }

  /** * Gets CKEditor 5 instance data as a HTML string. * * @return string * The result of retrieving CKEditor 5's data. * * @see https://ckeditor.com/docs/ckeditor5/latest/api/module_editor-classic_classiceditor-ClassicEditor.html#function-getData */
  protected function getEditorDataAsHtmlString(): string {
    
$text_format
        ))
      ));

      // If valid, save both.       $text_format->save();
      $text_editor->save();
    }

    $this->drupalGet($this->host->toUrl('edit-form'));
    $this->waitForEditor();
    $this->assertSame($expected_markup$this->getEditorDataAsHtmlString());
  }

  /** * Data provider for ::testAllowingExtraAttributes(). * * @return array * The test cases. */
  public function providerAllowingExtraAttributes(): array {
    $general_test_case_markup = '<div class="llama" data-llama="🦙"><p data-llama="🦙">The <a href="https://example.com/pirate" class="button" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" class="use-ajax" data-grammar="adjective">irate</a>.</p></div>';
    return [
      
    // seven changes:     // 1. the `red-heading` class has been added to the `<h2>`     // 2. the `history` class has been removed from the `<p>`, because CKEditor     // 5 has not been configured for this: if a Style had configured for it,     // it would have been retained.     // 3. the `items` class has been added to the `<ul>`     // 4. the `steps` class has been added to the `<ol>`     // 5. the `data-analysis` class has been added to the `<table>`     // 6. the `reliable` class has been added to the `<a>`     // 7. The `deep-dive` class has been added to the `<div>`     // 8. The `caution` class has been added to the `<caption>`     $this->assertSame('<h2 class="red-heading">Upgrades</h2><p>Drupal has historically been difficult to upgrade from one major version to the next.</p><p class="highlighted interesting">This changed with Drupal 8.</p><blockquote class="famous"><p>Updating from Drupal 8\'s latest version to Drupal 9.0.0 should be as easy as updating between minor versions of Drupal 8.</p></blockquote><p>— <a class="reliable" href="https://dri.es/making-drupal-upgrades-easy-forever">Dries</a></p><div class="deep-dive"><ul class="items"><li>Update Drupal core using Composer</li><li>Update Drupal core manually</li><li>Update Drupal core using Drush</li></ul><ol class="steps"><li>Back up your files and database</li><li>Put your site into maintenance mode</li><li>Update the code and apply changes</li><li>Deactivate maintenance mode</li></ol><table class="data-analysis"><caption class="caution">Drupal upgrades are now easy, with a few caveats.</caption><tbody><tr><td>First</td><td>Second</td></tr><tr><td>Data value 1</td><td>Data value 2</td></tr></tbody></table></div>', $this->getEditorDataAsHtmlString());
  }

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