Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
CKEditor plugins cannot access/return html content of selections unless they are wrapped in a containing div. data.content will return plaintext when wrapper is not present, due to CKEditor's selection.getSelectedElement() returning false in wysiwyg/editors/js/ckeditor-3.0.js.
Steps to reproduce
- Create or install a simple ckeditor plugin that uses a user's content selection
- Highlight some text in the wysiwyg that contains html, for example `
button<strong>bold</strong>
` - Observe that data.content from that selection returns plaintext with tags stripped out to your plugin
Proposed resolution
Use CKEditor's own methods for dealing with unwrapped HTML selections to wrap the selection in a containing div so it can be returned and used without stripping html from the selection.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | wysiwyg--3166182--2.patch | 766 bytes | audrey.brockhaus |
Comments
Comment #2
audrey.brockhaus CreditAttribution: audrey.brockhaus at Nerdery commentedThis patch works for me to access html selections in a plugin.
Comment #3
audrey.brockhaus CreditAttribution: audrey.brockhaus at Nerdery commented