Problem/Motivation
I use Drupal 10 and ckeditor 5, if I add a nbsp to a link, the link is split into two parts
for example :
before adding the nbsp : <a href="/"> content link </a>
after adding the nbsp : <a href="/">content </a> <a href="/"> link </a>
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | Capture d'écran 2024-06-04 090133.png | 18.05 KB | drunir |
Issue fork nbsp-3432756
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wengerkWe utilize the
insertContentfunction to inject HTML into CKEditor 5, which appears to be the recommended method for injecting model fragments (such as<nbsp> </nbsp>).Referencing our implementation in the nbspCommand.js file.
However, we've encountered an issue where using
insertContentwithin a link results in the link being split, as noted by @luci_ole.Despite searching the CKEditor 5 documentation and the Github Issue Queue, we haven't found a solution to prevent this behavior.
Any assistance in resolving this issue would be greatly appreciated. If any maintainers or individuals are aware of modules or implementations that successfully insert HTML within a link in CKEditor 5, we would be eager to examine their approach.
Comment #4
wengerkComment #5
wengerkIt was a schema issue as pointed by ksenzee on Slack https://drupal.slack.com/archives/C01GWN3QYJD/p1714662493560729?thread_t...
To solve the problem, I just changed the schema
Comment #7
wengerkMerged on dev branch 3.0.x
For people willing to use this fix before release of 3.0.2, please use the patch on Gitlab.
Comment #10
wengerkComment #12
wengerkGive credit to ksenzee for helping me pointing the issue on Slack
https://drupal.slack.com/archives/C01GWN3QYJD/p1714637176482069
Comment #13
drunir commentedThe test in #3 works fine, but when you add an "a" tag in wysiwyg, and add an "nbsp" tag inside it using the "non-breaking space" button, the "a" tag will be split !

Comment #14
wengerkComment #16
wengerkI've made a new batch of fix about how the command inject the nbsp tag. Should now propertly keep all AttributeElement and not break them (eg. breaking links).
Comment #23
wengerkFor thos willing to help reviewing the code, you can integrate this patch in a Drupal project using Composer & cweagans/composer-patches.
composer.jsonfile to apply the patch.composer update drupal/nbspin order to apply the patchComment #24
drunir commentedI tested the new patch, it works well for me, thanks @wengerk
Comment #25
wengerkComment #27
wengerkThanks for testing it ! merged in 3.0.x (dev) will made a new release asap