function CKEditor5MarkupTest::testFilterHtmlAllowedGlobalAttributes
Same name in other branches
- 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5MarkupTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5MarkupTest::testFilterHtmlAllowedGlobalAttributes()
Ensures that CKEditor 5 retains filter_html's allowed global attributes.
FilterHtml always forbids the `style` and `on*` attributes, and always allows the `lang` attribute (with any value) and the `dir` attribute (with either `ltr` or `rtl` as value). It's important that those last two attributes are guaranteed to be retained.
See also
\Drupal\filter\Plugin\Filter\FilterHtml::getHTMLRestrictions()
ckeditor5_globalAttributeDir
ckeditor5_globalAttributeLang
https://html.spec.whatwg.org/multipage/dom.html#global-attributes
File
-
core/
modules/ ckeditor5/ tests/ src/ FunctionalJavascript/ CKEditor5MarkupTest.php, line 127
Class
- CKEditor5MarkupTest
- Tests for CKEditor 5.
Namespace
Drupal\Tests\ckeditor5\FunctionalJavascriptCode
public function testFilterHtmlAllowedGlobalAttributes() : void {
$page = $this->getSession()
->getPage();
$assert_session = $this->assertSession();
// Add a node with text rendered via the Plain Text format.
$this->drupalGet('node/add/page');
$page->fillField('title[0][value]', 'Multilingual Hello World');
// cSpell:disable-next-line
$page->fillField('body[0][value]', '<p dir="ltr" lang="en">Hello World</p><p dir="rtl" lang="ar">مرحبا بالعالم</p>');
$page->pressButton('Save');
$this->addNewTextFormat();
$this->drupalGet('node/1/edit');
$page->selectFieldOption('body[0][format]', 'ckeditor5');
$this->assertNotEmpty($assert_session->waitForText('Change text format?'));
$page->pressButton('Continue');
$this->waitForEditor();
$page->pressButton('Save');
// cSpell:disable-next-line
$assert_session->responseContains('<p dir="ltr" lang="en">Hello World</p><p dir="rtl" lang="ar">مرحبا بالعالم</p>');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.