Skip to content

Commit

Permalink
Resolve #3432756 "Splitting the links"
Browse files Browse the repository at this point in the history
  • Loading branch information
WengerK committed May 6, 2024
1 parent 7814f26 commit 98cca11
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- fix tests on Drupal 10.2+ using HTML5 filter
- fix issue #3432756: Splitting the links in two

### Removed
- removed translation-files - Issue #3365383
Expand Down
2 changes: 1 addition & 1 deletion js/build/nbsp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions js/ckeditor5_plugins/nbsp/src/nbspEditing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default class NbspEditing extends Plugin {
const schema = this.editor.model.schema;
schema.register("nbsp", {
allowWhere: "$text",
allowAttributesOf: "$text",
isInline: true,
isObject: true,
});
}

Expand Down
29 changes: 29 additions & 0 deletions tests/src/FunctionalJavascript/DrupalCKEditor5NbspTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected function setUp(): void {
'toolbar' => [
'items' => [
'sourceEditing',
'link',
'bold',
'italic',
'nbsp',
Expand Down Expand Up @@ -170,4 +171,32 @@ public function testButton() {
$this->assertEquals(" ", $nbsp->firstChild->nodeValue);
}

/**
* Tests using Drupal Nbsp button to add non-breaking space into Link.
*/
public function testNbspInsideLinkTag() {
$this->drupalGet('node/add/page');
$this->waitForEditor();
$assert_session = $this->assertSession();
$assert_session->waitForElementVisible('css', '.ck-editor__editable', 1000);

// Emulate the user typing a link and adding an NBSP element inside.
$this->pressEditorButton('Source');
$source_text_area = $assert_session->waitForElement('css', '.ck-source-editing-area textarea');
$source_text_area->setValue('lorem ipsum <a href="https://www.google.ch">dolore<nbsp>&npbs;</nbsp>sit</a> amet.');

// Click source again to make source inactive and have the Schema refreshed.
$this->pressEditorButton('Source');

// The link should be left intact and we should have 1 NBSP element inside.
$xpath = new \DOMXPath($this->getEditorDataAsDom());
$nbsp = $xpath->query('//nbsp');
$this->assertCount(1, $nbsp);
$this->assertEquals(" ", $nbsp[0]->firstChild->nodeValue);

$link = $xpath->query('//a');
$this->assertCount(1, $link);
$this->assertEquals("dolore sit", $link[0]->textContent);
}

}

0 comments on commit 98cca11

Please sign in to comment.