function CKEditor5TestTrait::selectTextInsideElement
Same name in other branches
- 9 core/modules/ckeditor5/tests/src/Traits/CKEditor5TestTrait.php \Drupal\Tests\ckeditor5\Traits\CKEditor5TestTrait::selectTextInsideElement()
- 11.x core/modules/ckeditor5/tests/src/Traits/CKEditor5TestTrait.php \Drupal\Tests\ckeditor5\Traits\CKEditor5TestTrait::selectTextInsideElement()
Selects text inside an element.
Parameters
string $selector: A CSS selector for the element which contents should be selected.
2 calls to CKEditor5TestTrait::selectTextInsideElement()
- MediaTest::testEditableCaption in core/
modules/ ckeditor5/ tests/ src/ FunctionalJavascript/ MediaTest.php - Tests caption editing in the CKEditor widget.
- 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 145
Class
- CKEditor5TestTrait
- Provides methods to test CKEditor 5.
Namespace
Drupal\Tests\ckeditor5\TraitsCode
protected function selectTextInsideElement(string $selector) : void {
$javascript = <<<JS
(function() {
const el = document.querySelector(".ck-editor__main {<span class="php-variable">$selector</span>}");
const range = document.createRange();
range.selectNodeContents(el);
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
})();
JS;
$this->getSession()
->evaluateScript($javascript);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.