function CKEditor5TestTrait::getEditorDataAsHtmlString

Same name in other branches
  1. 10 core/modules/ckeditor5/tests/src/Traits/CKEditor5TestTrait.php \Drupal\Tests\ckeditor5\Traits\CKEditor5TestTrait::getEditorDataAsHtmlString()
  2. 11.x core/modules/ckeditor5/tests/src/Traits/CKEditor5TestTrait.php \Drupal\Tests\ckeditor5\Traits\CKEditor5TestTrait::getEditorDataAsHtmlString()

Gets CKEditor 5 instance data as a HTML string.

Return value

string The result of retrieving CKEditor 5's data.

See also

https://ckeditor.com/docs/ckeditor5/latest/api/module_editor-classic_cl…

4 calls to CKEditor5TestTrait::getEditorDataAsHtmlString()
CKEditor5TestTrait::getEditorDataAsDom in core/modules/ckeditor5/tests/src/Traits/CKEditor5TestTrait.php
Gets CKEditor 5 instance data as a PHP DOMDocument.
MediaTest::testConversion in core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
Tests that `<drupal-media>` is converted into a block element.
SourceEditingTest::testAllowingExtraAttributes in core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php
Tests allowing extra attributes on already supported tags using GHS.
StyleTest::testStyleFunctionality in core/modules/ckeditor5/tests/src/FunctionalJavascript/StyleTest.php
Tests Style functionality: setting a class, expected style choices.

File

core/modules/ckeditor5/tests/src/Traits/CKEditor5TestTrait.php, line 35

Class

CKEditor5TestTrait
Provides methods to test CKEditor 5.

Namespace

Drupal\Tests\ckeditor5\Traits

Code

protected function getEditorDataAsHtmlString() : string {
    // We cannot trust on CKEditor updating the textarea every time model
    // changes. Therefore, the most reliable way to get downcasted data is to
    // use the CKEditor API.
    $javascript = <<<JS
(function(){
  return Drupal.CKEditor5Instances.get(Drupal.CKEditor5Instances.keys().next().value).getData();
})();
JS;
    return $this->getSession()
        ->evaluateScript($javascript);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.