function CKEditor5TestTrait::getEditorDataAsHtmlString

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/Traits/CKEditor5TestTrait.php \Drupal\Tests\ckeditor5\Traits\CKEditor5TestTrait::getEditorDataAsHtmlString()
  2. 10 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…

5 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.
SourceEditingEmptyElementTest::testEmptyInlineElement in core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingEmptyElementTest.php
Tests creating empty inline elements using Source Editing.
SourceEditingTest::doTestAllowingExtraAttributes in core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php
Tests extra attributes with a specific data set.
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 37

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.